We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Inserting a string in a paragraph


I am getting the text/string value from a paragraph from a DOCX document, modifying the content and I want to set the modified string value to the same paragraph again.

I am getting the string using:


How to set the modified string to the same paragraph again ?

Prabhaker Kr

Hi Prabhaker,

Thanks for your inquiry. All text of the document is stored in runs of text. In your case, I suggest you Run.Text property to get or set the text. You may also use following code example to remove run nodes of Paragraph and add new Run node into Paragraph.

Moreover, I suggest you please read about Aspose.Words document object model from here:

Document doc = new Document(MyDir + "in.docx");
Paragraph paragraph = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 0, true);
Run run = new Run(doc, "modified text");
doc.save(MyDir + "Out.docx");