HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › General questions / FAQ › Different Header / Footer based on page number
- This topic has 3 replies, 3 voices, and was last updated May 28, 2013
07:48:30 byPD4ML.
-
AuthorPosts
-
November 4, 2011 at 13:15#26624
I would like to know if its possible to use a different header / footer based on the page number. This is practical for printing books, where the outside edge should contain the page number. This is only possible if you can reverse the header / foot template based on even / odd page number. Thanks in advance!
November 15, 2011 at 09:57#28711You can find general info regarding PD4ML headers/footers by the link:
html-pdf-faq-f1/pdf-page-headers-footers-definition-options-t41.htmlThe third option allows you to define with scope attribute where a particular header/footer should appear. You may define multiple
<pd4ml:page.header>tags with different scopes.If you prefer to define headers/footers via API, you need to override corresponding methods of PD4PageMark. For example:
PD4PageMark footer = new PD4PageMark() { public String getHtmlTemplate(int pageNumber) { if ( pageNumber % 2 == 0 ) { return "<html><body>some left aligned stuff..."; } else { return "<html><body>some right aligned stuff..."; } } }; pd4ml.setPageFooter(footer);The above example defines page-specific HTML footer. Such type of footers is not supported by PD4ML Std. For the Std verison you may override:
PD4PageMark.getPageNumberTemplate(int pageNr);
PD4PageMark.getPageNumberAlignment(int pageNr);
PD4PageMark.getTitleTemplate(int pageNr);
etcMay 27, 2013 at 14:39#28712I am currently evaluating this software, before deciding to buy the full license. It looks like there might be a limitation with regards to headers and footers. The example above demonstrates how to define page specific content, but as far as I can see there is no way to set page specific areaHeight.
I would like to render my first page without a header:
PD4PageMark out = new PD4PageMark(); out.setHtmlTemplate("...some header..."); out.setPagesToSkip(1); out.setAreaHeight(-1);The header is not displayed in the pdf, but the space it occupies (in subsequent pages) pushes the content down. Is there a way to solve this?
May 28, 2013 at 07:48#28713It is a functional limitation of the header/footer type. PD4ML supports 3 header/footer types – see https://pd4ml.com/cookbook/pdf_header_footer_generation.htm
An inline header should solve the issue.
-
AuthorPosts
The forum ‘General questions / FAQ’ is closed to new topics and replies.
