In This Topic
DsWord allows you to specify the set of indentation properties for a paragraph using the Indentation class which can be accessed using Indentation property of the ParagraphFormat class.
Get Indents
To get the indents 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 indentation properties applied to the paragraph using Indentation property of the ParagraphFormat class.
- Get indentation property. For example, get the value of the first line indent of the paragraph using FirstLineIndent property of the Indentation class.
- Display the indent value on the console.
C# |
Copy Code |
//Get indents
Console.WriteLine("Indent: " +
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Indentation.FirstLineIndent); |
Back to Top
Set Indents
To set the indents 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 indentation properties applied to the paragraph using Indentation property of the ParagraphFormat class.
- Set indentation property. For example, set the value of the first line indent of the paragraph using FirstLineIndent property of the Indentation class.
C# |
Copy Code |
//Set indents
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Indentation.FirstLineIndent = 20; |
Back to Top
For more information on how to implement paragraph indentation using DsWord, see DsWord sample browser.