Document Solutions for Word
Features / Paragraph / Indentation
In This Topic
    Indentation
    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:

    1. Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
    2. Access the paragraph formatting properties using Format property of the Paragraph class.
    3. Get the indentation properties applied to the paragraph using Indentation property of the ParagraphFormat class.
    4. Get indentation property. For example, get the value of the first line indent of the paragraph using FirstLineIndent property of the Indentation class.
    5. 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:

    1. Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
    2. Access the paragraph formatting properties using Format property of the Paragraph class.
    3. Get the indentation properties applied to the paragraph using Indentation property of the ParagraphFormat class.
    4. 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.