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

Free Support Forum - aspose.com

Header and footer not handled

Hi support,

I’m using the fix from December 05/2008.
Please check the following code:

Pdf pdf = new Pdf();
pdf.getSections().add();
Section sec2 = pdf.getSections().add();
Text txt2 = new Text(sec2, “this section has header and footer”);
sec2.getParagraphs().add(txt2);

HeaderFooter head1 = new HeaderFooter(sec2);
Text textHeader1 = new Text(head1, “Text header in section2”);
head1.getParagraphs().add(textHeader1);

HeaderFooter footer1 = new HeaderFooter(sec2);
Text textFooter1 = new Text(footer1, “Text footer in section2”);
footer1.getParagraphs().add(textFooter1);

sec2.setOddHeader(head1);
sec2.setEvenHeader(head1);
sec2.setOddFooter(footer1);
sec2.setEvenFooter(footer1);

pdf.save(new FileOutputStream(new File(“C:/Temp/TRS/pdf/HederFooterProblem.pdf”)));

Note that the header&footer don’t appear in the output. If you comment the 2nd line : “pdf.getSections().add();”, the output will be as expected.

Regards,
Milan

Hello Milan,

I have tested the scenario and I am able to notice the problem. We are looking into this matter and will keep you updated with the status of correction. We apologize for your inconvenience.

Hi milan,

The method “pdf.getSections().add()” means you have added a new Section to the document. As you don’t add any Paragraph to that Section (you add all things to another Section, sec2), that Section will render as a blank page. Maybe we will improve this, let the empty Section render nothing in the output in the future release.

Thank you for using our product.