Having trouble combining documents


#1

Hi,

I am combining documents with the following function:

public void CombineDocuments(Document dstDoc, Document srcDoc){
foreach (Section srcSection in srcDoc) {
Node dstSection = dstDoc.ImportNode(srcSection, true, ImportFormatMode.KeepSourceFormatting);
dstDoc.AppendChild(dstSection);
}
}

I think I found that sample code somewhere in the forum.

The problem I have is that when I combine certain documents(Doc1 and Doc2), the first page of Doc2 starts on the last page of Doc1 instead of on the "next" page.

Can I remove this issue with something on the source Word file side? On the Aspose component side?

Any help would be appreciated.


#2

Try adding

dstDoc.LastSection.PageSetup.SectionStart = SectionStart.NewPage;

after

dstDoc.AppendChild(dstSection);

If it does not help, then please attach the sample documents. I will check what could be done.

Best regards,