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

Free Support Forum - aspose.com

Page breaks not applying while mail merge

Hi Team,

We have implemented mail merge functionality. If we have multiple records in the datasource,
Instead of generating new page for each record it is appending the second record content below the first content.

I am sharing you the sample source word document what we are using for mail merge.Please find the attachment.

I am also sharing you the code snippet what we have written for merge.

Dim ms As MemoryStream = New MemoryStream()
Dim doc As New Document(filePath)
If (filetype = "doc") Then
doc.Save(ms, SaveFormat.Doc)
doc.Save(ms, SaveFormat.Pdf)
End If

Can you please suggest me the steps to resolve this issue.


Hi Krishna,

for your inquiry. Please
note that Aspose.Words inserts sections with the same type of template
document section while mail merge process for each record. Please see
the attached image for detail.

Please read how to control new pages during Mail Merge:

Please set the PageSetup.SectionStart property as ‘NewPage’ as shown in following highlighted code snippet to get the required output.

// Open the template document.
Document doc = new Document(MyDir + "sample.doc");
doc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;
// Execute mail merge.
doc.Save(MyDir + "Out.docx");