HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › General questions / FAQ › Is it possible to set header/footer scope via the API?
- This topic has 5 replies, 2 voices, and was last updated Apr 24, 2014
11:00:46 byPD4ML.
-
AuthorPosts
-
February 2, 2010 at 06:44#26326
I see that since PD4ML Pro 3.2.0b5 you support the ‘scope’ attribute for in
<pd4ml:page.header>and<pd4ml:page.footer>tags so we would be able to set (for example) different headers for the 1st and the other pages.
Thing is that we are currently using the API to set the header template and in the API docs on the site I do not find a way to set this scope programmatically. Am I missing something?March 14, 2010 at 05:45#27836It is possible with overriding of template methods. For example the code below defines different footers for even and odd pages.
PD4PageMark footer = new PD4PageMark() { public String getHtmlTemplate(int pageNumber) { if ( pageNumber % 2 == 0 ) { return "<html>...template 1...</html>"; } else { return "<html>...template 2...</html>"; } } }; footer.setAreaHeight(50);Please take into account – even if you define return “”; for some pages there, it will allocate the defined footer space 50px anyway.
footer.setAreaHeight(-1); autocomputes the footer heigh using the template code, returned for the first page.
The following methods of PD4PageMark are overridable:
- String getHtmlTemplate( int pageNumber )
- Color getPageBackgroundColor( int pageNumber )
- String getPageBackgroundImageUrl( int pageNumber )
- String getPageNumberTemplate( int pageNumber )
- String getTitleTemplate( int pageNumber )
- Font getFont( int pageNumber )
May 11, 2010 at 19:50#27837I have a dynamic first page footer, it may sometimes occupy more than half of the first page.
Looks like program computing footer height based on first page footer for all pages.Is there any way that I can force to compute footer height based on individual page footer content and adjust page content accordingly?
May 25, 2010 at 15:21#27838There are 3 ways to define headers or footers with PD4ML:
html-pdf-faq-f1/pdf-page-headers-footers-definition-options-t41.html
The first and the second (definition via PD4ML API) always allocate fixed amount of space.
The third option should do the trick for you.
April 23, 2014 at 19:03#27839I am also looking to compute the header height dynamically based on header size. Does anyone know how to do this using the API?
April 24, 2014 at 11:00#27840For HTML headers footer.setAreaHeight(-1) forces to allocate footer (or header) space, depending on an actual header height. The auto-computed height cannot change from page to page.
By inline header/footer definition (like
<pd4ml:page.header>) it can auto-compute header/footer height as well as change the allocated header space if header definition changes from page to page.If you do need an exact numeric height (in pixels) of a particular portion of HTML content, you may instantiate PD4ML, perform a dummy conversion of HTML portion to PDF and request the document height:
-
AuthorPosts
The forum ‘General questions / FAQ’ is closed to new topics and replies.
