Phantom PDF - page numbers inside content

  • I have a template where trough the data i give the number of pages that it will have, and trough a loop i generate each page.
    So i want to know if there is some way to have access to the number of pages and the current page.

    My idea is using an if to define some things that should not appear on the last page.

    On header and footer i have access to {#pageNum} and {#numPages} but i want to access it outside footer and header.

    Ps: I'm using jsreport 3.0.1, handlebars and phantom-pdf.

  • Handlebars each helper supports reaching the current item index using {{1}}. Doesn't this solve your problem? Seems it should when you mention you loop over each page.

  • No, because the template is of an invoice, an so it may have several versions (original, duplicate, triplicate), and each one may have several pages of products.
    And i'm using a for loop to iterate trough the pages of each version.
    This for loop is nested inside a each loop that iterates trough the versions.
    The ideal thing would be access {#pageNum} and {#numPages} inside the template.

  • I see. Unfortunately, there is no {#pageNum} available in the template content. This feature is provided by phantomjs and is only available in the header.

    These problems are often solved with the jsreport pdf-utils extension. Please take a look.
    However, I need to warn you, that it may not work fully with phantom-pdf. The phantomjs project is archived for a long time and we primarily support chrome recipes now.

  • Thanks
    For now, my application is in development, so later i will convert templates to chrome-pdf

Log in to reply

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