Header and footer not rendering properly in the PDF report's landscape page - jsreport



  • The header and the footer are not getting rendered properly on the landscape page of the report.
    The page number is not in sequence, the footer is not rendered completely and the header is not visible.

    This is my workspace:

    https://playground.jsreport.net/w/jitendra.shah/hMH2MZxZ

    As per the requirement, we need to add a landscape page in the report conditionally in the afterRender function. However, on the landscape page, the header is not rendered, page numbers are not in the sequence and footer styling is not getting applied properly to the whole page.



  • The merged header to a landscape-based template needs to have also landscape layout. This can be achieved using an extra prop and condition in the header template

    {{#if landscape}}
         @page {size: landscape}
    {{/if}}
    

    When you render the main template, you don't know the total number of pages yet, because you append another template afterward. To solve this you need to render everything twice. After the first render, you collect the information about the total pages and fill in the right values during the second render. See the updated workspace here

    https://playground.jsreport.net/w/anon/BZIoos3Z

    A similar problem is solved when building the table of contents, you can find it in the documentation here
    https://jsreport.net/learn/pdf-utils#toc-table-of-contents



  • Could you also suggest how to render the table of contents in this case?


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.