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

Free Support Forum - aspose.com

How to read header from top and footer from botton positions from WORD document as it is using aspose.words?

I want to read header from top and footer from botton positions from WORD document and the same settings we have to give in the final document


Thank you for inquiry. Please follow up the code snippet to import all header/footers from a document to another.

Section section = headerFooterSourceDocument.FirstSection;<o:p></o:p>

//int importFormatMode = (keepSourceFormat) ? ImportFormatMode.KeepSourceFormatting: ImportFormatMode.UseDestinationStyles;<o:p></o:p>

// Remove all HeaderFooter of the target document for each<o:p></o:p>

// Section<o:p></o:p>

for (int s = 0; s < document.Sections.Count; s++)<o:p></o:p>


if (document.Sections[s].HeadersFooters != null)<o:p></o:p>


while (document.Sections[s].HeadersFooters.Count != 0)<o:p></o:p>






<o:p> </o:p>

document.FirstSection.PageSetup.DifferentFirstPageHeaderFooter = section.PageSetup.DifferentFirstPageHeaderFooter;<o:p></o:p>

document.FirstSection.PageSetup.OddAndEvenPagesHeaderFooter = section.PageSetup.OddAndEvenPagesHeaderFooter;<o:p></o:p>

// Add content to the document (Import all HeaderFooter)<o:p></o:p>

for (int i = 0; i < section.HeadersFooters.Count; i++)<o:p></o:p>


// Import HeaderFooter<o:p></o:p>

<o:p> </o:p>

Node node = document.ImportNode(section.HeadersFooters[i], true,ImportFormatMode.KeepSourceFormatting);<o:p></o:p>

// Insert header footer into the first section of<o:p></o:p>

// document<o:p></o:p>



<o:p> Hope this will help.</o:p>