[]
GcWord allows you to add, modify, and delete a paragraph from a Word document. It allows you to add a paragraph to the paragraph collection using Add method of the ParagraphCollection class, modify it using the Paragraphs property which accesses the paragraph collection, and delete it using the Delete method of the ContentObject class.
To add a paragraph to a document:
Access the paragraph collection using Paragraphs property of the RangeBase class.
Add a paragraph using Add method of the ParagraphCollection class.
//Add first paragraph
doc.Body.Sections.First.GetRange().Paragraphs.Add("Hello, World!");
//Add another paragraph
doc.Body.Sections.First.GetRange().Paragraphs.Add("Grapecity Document Solution: GcWord");
//Save the document
doc.Save("AddParagraph.docx");
To modify a paragraph in a document:
Access the paragraph you want to modify from the paragraph collection using Paragraphs property of the RangeBase class. For example, access the first paragraph using First property of the ParagraphCollection class.
Modify the Paragraph class properties. For example, use the Format property for accessing the paragraph formatting properties such as the Alignment property to set the alignment of the paragraph.
doc.Load("AddParagraph.docx");
//Modify settings of the first paragraph
doc.Body.Sections.First.GetRange().Paragraphs.First.Format.Alignment = ParagraphAlignment.Center;
//Save the document
doc.Save("ModifyParagraph.docx");
To delete a paragraph from a document, access a paragraph from the paragraph collection using the Paragraphs property and delete it using Delete method of the ContentObject class.
doc.Load("AddParagraph.docx");
//Delete the last paragraph
doc.Body.Sections.First.GetRange().Paragraphs.Last.Delete();
//Save the document
doc.Save("DeleteParagraph.docx");
For more information on how to work with paragraphs using GcWord, see GcWord sample browser.