Free Support Forum - aspose.com

Trailing blank page - Mergefields - ExecuteWithRegions

I have a merge field word template which loops through a table and repeats the content between the <> and <>. If my input dataset has 3 records and if I want the contents of every record to start on a seperate page how can I do that? I tried inserting a page break right before the <> merge field and it does make every record start on a seperate page except it is generating a blank page at the end. So if there are 3 records it is spitting out 4 pages document and the 4th page is blank.

I am using MailMerge.ExecuteWithRegions(dtOutput) method to generate the document. I am attaching my template that I am trying to merge.

How can I fix this issue? Please help me.

Thanks,

Naga

Please also attach the document after being malmerged.

Here is how the document looks after performing mailmerge.

Adding the following code

doc.LastSection.Body.LastChild.Remove();

doc.LastSection.Body.LastChild.Remove();

after MailMerge will solve the problem.

Best regards,

The code you gave me worked and fixed my problem. Thanks for the help.