I’m adding a whole document to another document using builder. First I create a section, add some headers/footers, and then call InsertDocument. And it kills header and footer at that section.
There is my code:
builder.InsertBreak(BreakType.SectionBreakNewPage);
currentSection = builder.CurrentSection;
pageSetup = currentSection.PageSetup;
pageSetup.DifferentFirstPageHeaderFooter = false;
currentSection.HeadersFooters.LinkToPrevious(false);
// header
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.StartTable();
// some stuff here
var table = builder.EndTable();
table.ClearBorders();
// content
builder.MoveToDocumentEnd();
var doc = new Aspose.Words.Document(data.result.resultFileName);
builder.InsertDocument(doc, ImportFormatMode.UseDestinationStyles, new ImportFormatOptions() {
IgnoreHeaderFooter = true,
KeepSourceNumbering = false,
SmartStyleBehavior = true,
});