Table of Contents |
---|
Inserts an empty paragraph at the end of the specified Element. This method applies the specified named style to the paragraph.
Inserts an empty paragraph at the end of the specified Element. This method applies a specified named style and a set of formatting properties to the paragraph. The formatting properties will override the style's properties
Inserts an empty paragraph at the beginning of the specified Element. This method applies the specified named style to the paragraph.
Inserts an empty paragraph at the beginning of the specified Element. This method applies a specified named style and a set of formatting properties to the paragraph. The formatting properties will override the style's properties
Inserts an empty paragraph at a specified position within an Element. A Position object represents a cursor. This method applies the specified named style to the paragraph.
Before adding a paragraph to your file, you must create a content region in which to insert the paragraph. Each editable region in a Word file is represented by an Element object, or an object that extends Element, such as a Document object.
To insert an empty paragraph, use one of the methods listed at the beginning of this section. All of the methods take a style argument, which specifies a named style to apply to the inserted paragraph. The style argument may be null. If it is null, the Normal style will be applied to the paragraph. The Normal style is the default style used by Microsoft Word. The following inserts an empty paragraph at the end of the document and applies the BodyText style to the paragraph:
To add text to the paragraph, call one of the Element class's InsertTextAfter or InsertTextBefore methods. You can apply a font to the text by passing a Font object to InsertTextAfter or InsertTextBefore. The following lines create a Font object that we will use later when adding text to the paragraph:
The method InsertTextAfter takes a string and inserts it at the end of the paragraph. The method's second parameter specifies a Font object (created above) to apply to the text.
The Paragraph class provides numerous formatting properties. The following left-justifies the paragraph:
You can access existing paragraphs through the Element.Elements property, for example:
Paragraph Formatting
To apply a font to text in a paragraph, create a Font object and pass it to Paragraph.InsertTextAfter or Paragraph.InsertTextBefore, as demonstrated above.
Other paragraph formatting can be applied through the Paragraph object or the ParagraphFormatting object. To create a ParagraphFormatting object, call Document.CreateParagraphFormatting:
Next, set ParagraphFormatting properties.
To assign the ParagraphFormatting object that you created to a paragraph, pass it to Element.InsertParagraphAfter or Element.InsertParagraphBefore when you create a new paragraph.