pdf utils: pass value from main-template to header



  • Hi,

    I have a invoice template and I want to pass the invoice-id to the header to print it on every page. And I can pass the value with handlebars like this to pdf-utils:

    <span>{{invoiceid}}</span>{{{pdfAddPageItem invoiceid}}}
    

    But I don't understand how to access this value on the header template?
    It should be accessible like $pdf.pages[x].items[y]. What stands x and y for?

    I tried 0 and 0 because it is on page 1 and it is the first (and only) item I add with pdfAddPageItem. So I added this to the header template:

    {{$pdf.pages[0].item[0]}}
    

    But I think I'm getting something wrong here...
    Should be a rather simple task, I geuss.

    Reto E.



  • I got it working.

    The correct syntax is:

    <span>{{../$pdf.pages.[0].items.[0]}}</span>
    

    But the funny thing is, the assignment of a value does not always work. The pdfAddPageItem above does not work. But if I put it a few lines later after a $localizedResource it works:

    {{$localizedResource.invoce}}{{{pdfAddPageItem invoiceid}}}
    

Log in to reply
 

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