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

Free Support Forum - aspose.com

Each page- different header based on a default header

Hi,

I would like to create a different header for each page of my doc.
Is it possible with Aspose.Words?

And is it possible to add a default header in all pages of the document, with a different text in some of them ?

Thanks,

Q.

Hi

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

Thanks for your request. You can create different header/footer for each page in case of using a separate section for each page of your document.

Also, you can easily create different headers/footers for the first page and for odd/even pages. Please see the following link to learn more about creating headers and footers in Aspose.Words:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/howto-create-headersfooters-using-documentbuilder.html

Hope this helps.

Best regards,

Hi,

Thanks for your help, but I have some trouble using a different header for each page.
It’s ok with the first and primary, but after, I cannot have different header on the other pages.

Do you have a code sample which will help me to add a different header in each page ?

Thanks,

Quentin

Hi Quentin,

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

Thanks for your inquiry. Actually, there is no “page” concept in MS Word documents. MS Word document consists of one or more Sections. Each Section has Body (main content) and 3types of Header and Footers.

Header and footer can be First Page (displayed only on the first page of the section), Primary (displayed on other pages of the document) and Even (displayed on even pages). So basically, you can define different Headers/Footers for first page, even pages and other pages.

If you need to define different Headers/Footers for each page of your document you can go two ways:

1. If each page of your document is a separate section, then you can just define different Headers/Footers for each section in your document.

2. Another way to have different headers/footers on each page is using conditional logic. Using IF field you can define the following logic in your header or footer.

{ IF "{ PAGE }" = "2" "this is header of the second page" "this is not the second page" }

Such approach is good if you have not many pages in your document. But if you have a lot of pages, the conditional expressing will become too complicated.

Could you please provide me more information about your requirements? Maybe I will be able to suggest an easier way to achieve what you need. What kind of document do you need to generate? Could you attach a sample document here?

Best regards.

Thanks for your valuable help !

I didn’t understand the concept of sections and pages but now it’s ok.

Thank you very much.