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

Free Support Forum - aspose.com

Merging Documnets

Hi,
i am merging two documents into single but facing problem during merge. When i am appending document and if there is some space on last page it is appending into same page. I want that when i will append, it will start append from new page, not from last page.

code i am using is :

Document docall_final = new Document("…/doc1.doc");
Document doc_current = new Document("…/doc2.doc");
docall_final.AppendDocument(doc_current, ImportFormatMode.KeepSourceFormatting);
docall_final.Save("…/doc1.doc");

thanks

Hi Shivam,

Thanks for your inquiry. Could you please attach your input and expected output Word documents here for testing? We will investigate the issue on our side and provide you more information.

hi,
I am attaching the document and code that i am using.

code:
for(int i=2;i<4;i++)
{
Document doc1 = new Document(“1.doc”);
Document doc2 = new Document(“i+”.doc");
doc1.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);
doc1.Save(“1.doc”);
}

Hi Shivam,

Thanks for sharing the documents. Please set the value of PageSetup.SectionStart property as SectionStart.NewPage for the first section of document to get the desired output.

Document doc1 = new Document(MyDir + "1.doc");

for (int i = 2; i < 4; i++)

{

Document doc2 = new Document(MyDir + i + ".doc");

doc2.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;

doc1.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);

}

doc1.Save(MyDir + "Out v16.12.0.doc");