Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #26326

    I see that since PD4ML Pro 3.2.0b5 you support the ‘scope’ attribute for in and 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?


    It is possible with overriding of template methods. For example the code below defines different footers for even and odd pages.

    [language=java:ajrznd4t]PD4PageMark footer = new PD4PageMark() {
    public String getHtmlTemplate(int pageNumber) {
    if ( pageNumber % 2 == 0 ) {
    return “…template 1…“;
    } else {
    return “…template 2…“;

    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 )

    I 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?


    There are 3 ways to define headers or footers with PD4ML:


    The first and the second (definition via PD4ML API) always allocate fixed amount of space.

    The third option should do the trick for you.


    I am also looking to compute the header height dynamically based on header size. Does anyone know how to do this using the API?


    For 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 ) 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:

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘General questions / FAQ’ is closed to new topics and replies.