Free Support Forum -

Combining documents and maintaining page layout

Greetings -

I have an automated mail merge process that appends a series of Word documents together and then executes a mail merge. The problem I'm running into is that it appears that occaisonally one document will have significant white space on it's last page, so that when the next document in the serries is appended, it doesn't start on a new page. I need to be able to append these documents together but have each component document start on a new page.

Currently the code I'm using to append the documents is like this:

string currentPath = rootPath + component.ComponentPath;

Trace.WriteLine(string.Format("[CreateClaimsDocument]: Current template path is {0}",currentPath));

Aspose.Words.Document currentDocument = new Aspose.Words.Document(currentPath);

for (int i = 0; i < currentDocument.Sections.Count; i++)


Aspose.Words.Section newSection = (Aspose.Words.Section)wordDocument.ImportNode(currentDocument.Sections[i],true);



I've tried a few different things using DocumentBuilder.InsertBreak but that seems to always result in blank pages in the combined document.

Any suggestions on how I can append all these documents together and preserve the page breaks would be greatly appreciated.



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

Thanks for your request. I think that you can set SectionStart = SectionStart.NewPage. For example see the following code:

//Open documents

Document dstDoc = new Document(@"Test043\in1.doc");

Document srcDoc = new Document(@"Test043\in2.doc");

//Loop through all section in source document

foreach (Section sect in srcDoc.Sections)


//Import section

Section newSect = (Section)dstDoc.ImportNode(sect, true, ImportFormatMode.KeepSourceFormatting);

if (sect.Equals(srcDoc.FirstSection))


//If section is first one in the source document

//then set sectiton to start from next page

newSect.PageSetup.SectionStart = SectionStart.NewPage;


//Add section to destination document



//Save document


Hope this helps.

Best regards.

Thanks so much for your reply, that did the trick! I figured it was something easy like that, just couldn’t figure out what it was.