We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to have one source item per page with MailMerge ?

Thread ID:





127171 Oct 31,2016 03:25 PM UTC Nov 3,2016 05:16 AM UTC ASP.NET Core 3
Tags: DocIO
Delphine Lacour
Asked On October 31, 2016 03:25 PM UTC


I have a Word template and I am using it with MailMerge and several sources. I would like one page per source.
I have manage to do that by adding a page break at the end of the template but I always have an extra blank page at the end of the document.

Could you tell me how I can remove this page or if you have another solution to have a source item per page ?


Priyanga Elangovan [Syncfusion]
Replied On November 1, 2016 01:10 PM UTC

Hi Delphine,

Thank you for contacting Syncfusion support.

Based on the given details, we have assumed that your requirement is to perform mail merge with various data source(records) and maintain each record in each page.

We suspect that you have added the pagebreak at the end of the template document. Due to this reason the extra page is added at the end of resultant document. So please remove the pagebreak from the template document.

You can utilize the mail merge event functionality of DocIO to insert the page break at the end of merge fields during mail merge to maintain each record in each page. Please skip to insert the page break at the time of last record binding to remove the extra page at end of the resultant document.

Kindly refer the following UG documentation link to know more details about mail merge event

Please find the template document and code snippet from below.
Template Document:

Code snippet:
//Loads the template document 
WordDocument document = new WordDocument(@"Template.docx"); 
//Gets the employee details as “IEnumerable” collection  
List<Employee> employeeList = GetEmployee(); 
//Creates an instance of “MailMergeDataTable” by specifying mail merge group name and “IEnumerable” collection. 
MailMergeDataTable dataTable = new MailMergeDataTable("Employee", employeeList); 
//Performs the mail merge event to insert the page break 
document.MailMerge.MergeField += new MergeFieldEventHandler(MergeField_InsertPageBreak); 
//Performs Mail merge 
//Saves and closes the Word document instance 
//Sets the employee details 
public static List<Employee> GetEmployee() 
List<Employee> employees = new List<Employee>()
new Employee("Nancy", "Sales Representative", "Tacoma")); 
employees.Add(new Employee("Andrew", "Sales Representative", "Tacoma")); 
employees.Add(new Employee("Janet", "Sales Representative", "Tacoma")); 
employees.Add(new Employee("Margaret", "Sales Representative", "Tacoma")); 
employees.Add(new Employee("Steven", "Sales Representative", "Tacoma")); 
return employees; 
//Creates the employee class. 
public class Employee 
public string FirstName { get; set; } 
public string Address { get; set; } 
public string Title { get; set; } 
public Employee(string firstName, string title, string address) 
FirstName = firstName; 
Title = title; 
Address = address; 
//Declare this variable in main class 
static int i = 1; 
static List<Employee> employeelist = GetEmployee(); 
//Creates the mail merge event to insert the page break 
private static void MergeField_InsertPageBreak(object sender, MergeFieldEventArgs args){ 
if (args.FieldName == "Address" && i != employeelist.Count) 
//Gets the owner paragraph 
WParagraph paragraph = args.CurrentMergeField.OwnerParagraph; 
//Appends the page break 

If we misunderstood any of your requirement, then Kindly revert to us with the code snippet/sample along with the input template document which you have used to reproduce the mentioned issues and your working scenario. Thereby we will analyze further on the mentioned case and will provided you appropriate solution.


Delphine Lacour
Replied On November 2, 2016 10:28 AM UTC


your perfectly understood what I wanted to do. 
Thanks for the solution.

Vijay Ramachandran [Syncfusion]
Replied On November 3, 2016 05:16 AM UTC

Hi Delphine,

Thank you for your update.

We are happy to hear that the provide solution solved your problem. Please let us know if you have any other questions. We will be happy to assist you as always.

Vijay R


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon