In This Topic
DsWord allows you to specify line spacing for a paragraph using LineSpacing property of the Spacing class which can be accessed using Spacing property of the ParagraphFormat class.
Get Line Spacing
To get the line spacing of a paragraph:
- Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
- Access the paragraph formatting properties using Format property of the Paragraph class.
- Get the spacing properties applied to the paragraph using Spacing property of the ParagraphFormat class.
- Get the value of the line spacing for the paragraph using LineSpacing property of the Spacing class.
- Display the line spacing value on the console.
C# |
Copy Code |
//Get line spacing
Console.WriteLine("Line spacing:" +
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Spacing.LineSpacing); |
Back to Top
Set Line Spacing
To set the line spacing of a paragraph:
- Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
- Access the paragraph formatting properties using Format property of the Paragraph class.
- Get the spacing properties applied to the paragraph using Spacing property of the ParagraphFormat class.
- Set the line spacing rule using LineSpacingRule property of the Spacing class.
- Set the value of the line spacing for the paragraph using LineSpacing property of the Spacing class.
C# |
Copy Code |
//Set line spacing
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Spacing.LineSpacingRule =
LineSpacingRule.Exact;
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Spacing.LineSpacing = 30; |
Back to Top
For more information on how to implement line spacing using DsWord, see DsWord sample browser.