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

Free Support Forum - aspose.com

How to remove Header Footer from the document?

Hi,



How to remove page header and footer for the specific page while rest of the pages will have them.



e.g.

In a 5 pages document we need header footer to be set on page 1,2 and 5.

How to skip them on 3 and 4.



Best Regards,

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. There is no way to remove header/footer from the particular page. You can only have different headers/footer for first page of section or for even/odd pages.

However, if each page is as separate section, you can remove headers/footers from the particular section.

doc.Sections[1].HeadersFooters.Clear();

Best regards.

Thanks very much for your quick response.



Is it possible to find out that the we have reached to the end of the current document by accessing any parameter in code?



Best Regards

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. If you iterate through paragraphs you can use Paragraph.IsEndOfDocument.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.paragraph.isendofdocument.html

Best regards.

I tried this Paragraph.IsEndOFDocument, but we have to place MoveToDocumentEnd to apply Header/Footer its of not use in our code snippet…its always true…



Is it possible to find out whether the Header/Footer is applied for the current document



best regards,

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can check whether each section contains header/footer. See the following code:

//Open document

Document doc = new Document(@"Test159\in.doc");

//loop through all sections

foreach (Section sect in doc.Sections)

{

int sectIdx = doc.Sections.IndexOf(sect);

if (sect.HeadersFooters.Count <= 0)

{

Console.WriteLine(string.Format("Section #{0} does not have header/footer", sectIdx));

}

else

{

Console.WriteLine(string.Format("Section #{0} contains header/footer of type:", sectIdx));

foreach (HeaderFooter hf in sect.HeadersFooters)

{

Console.WriteLine(string.Format("\t{0}", hf.HeaderFooterType));

}

}

}

Hope this helps.

Best regards.