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

Free Support Forum - aspose.com

Add one extra paragraph after mail merge with regions finished

Hi,

I have mail merge with regions for multiple records from datasource, how can I add one paragraph at the very end of the output? Thank you.

Regards

Hi Lan,


Thanks for your inquiry.

In my opinion, you could simply insert a Bookmark at a place where you would like to insert a paragraph in Word document. Then by using MoveToBookmark method of DocumentBuilder class move the cursor to that location and finally insert some paragraph (rich content) there. Please see the following code snippet for clarification:

Document doc = new Document(@“c:\test\BookMark.docx”);<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>

<o:p> </o:p>

builder.MoveToBookmark(“myBookMark”);<o:p></o:p>

builder.Write(“Your paragrapgh goes here”);<o:p></o:p>

<o:p></o:p>

Bookmark bookmark = doc.Range.Bookmarks[“myBookMark”];<o:p></o:p>

// You could optionally delete this bookmark. The bookmarked text is not deleted.<o:p></o:p>

bookmark.Remove();<o:p></o:p>

<o:p> </o:p>

doc.Save(@“c:\test\BookMark_out.docx”);


I hope, this will help.

Best Regards,

Thank you, Awais.