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");