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