Here is a problem reported by one of our users:
We are creating our reports with Aspose Words.
Before we buy a license we want to ensure all functionalities are covered.
Till now everything was going on well, except following points:
- Cannot set the header and/or footer of the first page only (not for all pages !!). If I set the header with “Aspose.Words.HeaderFooterType.HeaderFirst”, then the header is never shown. If I set the header with “Aspose.Words.HeaderFooterType.HeaderPrimary”, then it is shown in all pages, which is not desired.
- The header and footer show 2 lines crossing them, which is not desired in our reports.
And here is the answer.
Concerning defining different headers/footers for the first page. First you need to create a header/footer of HeaderFooterType.HeaderFirst/HeaderFooterType.FooterFirst type, fill it with data, and add it to section’s HeadersFooters collection. I can see that you have already done this. Then you need to enable showing different headers/footers for the foirst page in your document. That is controlled by PageSetup.DifferentFirstPageHeaderFooter property, which needs to be set to true. This property actually corresponds to File |Page Setup | Layout| Different first page setting in MS Word 2003.
Generally, there is a good example of header/footer creation that I have written some time ago. Here is a link to it:
There is also a similar article in offline documentation in Code Examples section.
I would also recommend you to use templates premade in MS Word for document generation. Everything that is common to generated documents should be put there. That is preferrable to creating documents from scratch using DocumentBuilder, because it is much more convenient to design templates visually in MS Word then create them from code.
As for the two lines in headers/footers - I really don’t have enough information to understand why are they present there and how you can get rid of them. You need to provide more info, and probably attach you document templates and generated document samples and also code that you use for document generation so that I could give you some meaningful recommendation.