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

    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 spacing properties applied to the paragraph using Spacing property of the ParagraphFormat class.
    4. Get the value of the line spacing for the paragraph using LineSpacing property of the Spacing class.
    5. 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:

    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 spacing properties applied to the paragraph using Spacing property of the ParagraphFormat class.
    4. Set the line spacing rule using LineSpacingRule property of the Spacing class.
    5. 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.