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

Free Support Forum - aspose.com

Need help in maintaining Header Footer across all pages

Hello Team,

I have one main document with specific header and footer.

Now I am appending one more document to this document, which also has different header footer. But I want my final document to have all pages with same header footer that main document has.

Let me know how can I achieve this. Thanks in advance.


@HardikS To achieve this you should remove headers and footers from the source document. In this can headers and footers will be inherited from the previous section. For example see the following code:

Document dst = new Document(@"C:\Temp\dst.docx");
Document src = new Document(@"C:\Temp\src.docx");

// Remove header and fooers from the source document
// and set the same header/footer options as in the last dst document section.
foreach (Section s in src.Sections)
    s.PageSetup.DifferentFirstPageHeaderFooter = dst.LastSection.PageSetup.DifferentFirstPageHeaderFooter;
    s.PageSetup.OddAndEvenPagesHeaderFooter = dst.LastSection.PageSetup.OddAndEvenPagesHeaderFooter;

dst.AppendDocument(src, ImportFormatMode.KeepSourceFormatting);

Thanks, it is working fine.


1 Like