Free Support Forum -

Why mail merge output document is appended with an extra page

Hello there,

I am calling mail merge - ExecuteWithRegions(ds) but the output document is always appended with an extra page at the end of document.

This may be because of the reason that I am calling InsertBreak after inserting MergeFields at the top and bottom of my source document.

DocumentBuilder docBuilder = new DocumentBuilder(objTemplateDocument);
docBuilder.InsertField(“MERGEFIELD TableStart:Properties”, “«TableStart:Properties»”);
docBuilder.InsertField(“MERGEFIELD TableEnd:Properties”, “«TableEnd:Properties»”);

But, if I don’t call docBuilder.InsertBreak(BreakType.PageBreak); then all the merge records are just appended one after another,
whereas I want them on separate page.
FYI, My source document is one page template.

Please guide.
I have attached my source document as well as output docs with/without InsertBreak().

Thank you!


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I think it is not good to insert page break at the end of your template. I think it is better to use PageBreakBefore option of paragraph. Please see the following code snippet:


docBuilder.ParagraphFormat.PageBreakBefore = true;

docBuilder.InsertField("MERGEFIELD TableStart:Properties", "«TableStart:Properties»");


docBuilder.InsertField("MERGEFIELD TableEnd:Properties", "«TableEnd:Properties»");

Also, I think the following article could be useful for you:

Hope this helps.

Best regards,

Thanks for your help Alexey,
setting PageBreakBefore = true solved the problem.