Insert in existing document

Nov 29, 2013 at 7:50 AM

is there a way to insert paragraphs into an existing document? As far as I can see, the InsertParagraph methods do an add.

Dec 3, 2013 at 5:20 AM
Yes, you can. Haven't tested this exact code, but it should work with something similar to this:

DocX doc = DocX.Load("test.docx");

Paragraph newParagraph = new Paragraph();
newParagraph.Text = "hello";

//Isnert paragraph after the last paragraph in the document:
doc.Paragraphs[doc.Paragraphs.Count - 1].InsertParagraphAfterSelf(newParagraph);

Dec 4, 2013 at 7:00 AM
The ctor of Paragraph is internal, but it works that way:
var para = doc.InsertParagraph(0, "hello", false);
Thank you!