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

Free Support Forum - aspose.com

Insert a page break before the insert in the target document of another document

I have several documents to insert into a target document. they should each begin on a new page of the target document.What are the possibilities for this ?

Hi
György,


Thanks for your inquiry. Please follow up the code snippet to combine multiple documents.

Document
dstDoc = new Document(“d:/temp/Poetry0.docx”);<o:p></o:p>


Document srcDoc = new Document("d:/temp/Poetry1.docx");

srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;

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("d:/temp/Poetry5.docx");


In case of any ambiguity, please let me know.


Thx !