Hi,
I am trying to merge 4 (can be any number of) word documents via Document builder. I want to retain the headers and footers on the original documents as it is on the final merged document. But, the final document is having the header only on the first page, the rest of the pages/documents do not have any headers set. some of these documents are multi pages and have “first page header only” set on them. I wonder if that is causing the issue.
Please find below the code I am using (simplified):
DocumentBuilder builder = new DocumentBuilder(); // top level document builder which will merge all these forms
foreach (var template_stream in documentsWithDocType)
{
Document mergedDocument = new Document(template_stream);
mergedDocument.FirstSection.PageSetup.DifferentFirstPageHeaderFooter = false;
builder.InsertDocument(mergedDocument, ImportFormatMode.KeepSourceFormatting, new ImportFormatOptions() { IgnoreHeaderFooter = false });
builder.InsertBreak(BreakType.PageBreak);
}
builder.Document.Save(output_stream, SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Docx));