Documents for Word, .NET Edition
Features / Paragraph / Paragraph Styling
In This Topic
    Paragraph Styling
    In This Topic

    GcWord allows you to define a style using Style class which can be accessed using Styles property of the Run class. It allows you to apply the defined style to a paragraph using Style property of the Paragraph class.

    Set Paragraph Style

    To set the paragraph style:

    1. Define a new style using the Style class of type Paragraph using the StyleType enumeration and add it to the style collection using Add method of the StyleCollection class.
    2. Get the character formatting of the paragraph using Font property of the Style class.
    3. Set the character formatting using the FontBase class properties. For example, set the name of the font using the Name property and format the font as bold and italics using the Bold and Italic properties respectively.
    4. Apply the defined style on the paragraph using Style property of the Paragraph class.
      Copy Code
      //Add style to the first paragraph
      Style sPara = doc.Styles.Add("ParaStyle", StyleType.Paragraph);
      sPara.Font.Name = "Times New Roman";
      sPara.Font.Bold = true;
      sPara.Font.Italic = true;
      doc.Body.Sections.First.GetRange().Paragraphs.Last.Style = sPara;
    Back to Top

    For more information on how to implement paragraph styling using GcWord, see GcWord sample browser.