Hello,
I am using the code below to combine two documents together:
Aspose.Words.Document dstDoc = new Aspose.Words.Document(@"F:\Temp\1.doc");
Aspose.Words.Document srcDoc = new Aspose.Words.Document(@"F:\Temp\2.doc");
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
AppendDoc(dstDoc, srcDoc);
dstDoc.Save(@"f:\temp\res.doc");
public void AppendDoc(Aspose.Words.Document dstDoc, Aspose.Words.Document srcDoc)
{
foreach (Aspose.Words.Section srcSection in srcDoc)
{
Aspose.Words.Section newSection = (Aspose.Words.Section)dstDoc.ImportNode(srcSection, true, Aspose.Words.ImportFormatMode.KeepSourceFormatting);
dstDoc.Sections.Add(newSection);
}
}
On occasion, the joined document has a page break between the two documents although when I view the formatting of the individual documents in word they do not have page breaks. The reason it is happening is because the PageWidth and PageHeight are very slightly different between the two documents. I have been able to resolve it by setting the PageWidth/PageHeight of the two documents to be the same - is this behaviour by design or perhaps is this a bug that I have identified. If there is another work-around you could recommend I would appreciate details.
Thank you very much for your help
Regards