Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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?

    #27836

    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…“;
    }
    }
    };
    footer.setAreaHeight(50);[/language:ajrznd4t]

    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 )
    #27837

    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?

    #27838

    There 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.

    #27839

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

    #27840

    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:

    http://pd4ml.com/cookbook/pd4ml_conversion_status.htm

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

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