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

Free Support Forum - aspose.com

Difference between merging and appending

can you pls let me know what is the difference between merging and appending...the below two codes shows how to merge and append documents.. Is both codes functionality works same ?i mean can we use any one of the code?

---------------------appending code---------------

Document srcdoc = new Document(@"C:\test.docx");//--current
Document dstdoc = new Document(@"C:\blank.docx");//--Dest
dstdoc.AppendDocument(srcdoc, ImportFormatMode.KeepSourceFormatting);

--------------------merging code-------------------

Document dstDoc = new Document(@"C:\Test.docx");//Paper size of this document is A4
Document srcDoc = new Document(@"C:\Test1.docx");//Paper size of this document is Letter
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
foreach (Section srcSection in srcDoc)
{
srcSection.PageSetup.PageWidth = dstDoc.LastSection.PageSetup.PageWidth;
srcSection.PageSetup.PageHeight = dstDoc.LastSection.PageSetup.PageHeight;
//Import section
Section newSection = (Section)dstDoc.ImportNode(srcSection, true, ImportFormatMode.KeepSourceFormatting);
dstDoc.Sections.Add(newSection);
}
//Save output
dstDoc.Save(@"C:\TestResult.docx");

Hi

Thanks for your request. In older version there was no a built-in AppendDocument method. So our customers had to loop through all sections in source document and append them to the end of the destination to merge two documents. In newer versions of Aspose.Words we introduced a built-in AppendDocument method, which actually does the same but needs less coding from your side.

Best regards,