How can i get information from main template to footer template?



  • Hi guys, how can i get information from main template to a footer template?
    In the main template i have a loop like this
    {{#each Invoices}}
    {{N_invoices}}
    {{/each}}

    how can I pass the value of {{N_invoices}} to a footer template? And how can I use it?



  • Unfortunately, this is not possible. The header/footer is completely separate part for phantomjs.



  • oh ok. There isn't any chance to have the same value of N_invoices of the main template with and another N_invoices (that i get from another {{each}}) in the footer template ?
    Another questions:
    I notice that i can use function of the main template. How can i pass {#pageNum} as arguments of a function?


  • administrators

    oh ok. There isn't any chance to have the same value of N_invoices of the main template with and another N_invoices (that i get from another {{each}}) in the footer template ?

    unfortunately no, phantomjs does not give us a way to pass the data in the current context (current each) to headers and footers.. in fact, right now, any engine that is based on html to pdf conversion does not have that feature. but we hope that someday (and motivated by the release of chrome headless) a feature like that can be possible and let us release a version with more control of header and footer.

    I notice that i can use function of the main template. How can i pass {#pageNum} as arguments of a function?

    sorry, i don't understand the question, which function are you referring to? can you make a screenshot of the place where you see it in the studio? anyway, pageNum is a value that is just available when the header/footer are being rendering, right now it can't be shared outside of that context, basically header and footer are not very powerful because of the lack of features in the html to pdf converter (in this case, phantomjs).



  • I can use, in the footer template, all javascript functions that i create in the main template, i was wondering if i could use that for my purpose.
    Thanks for your reply guys. I'll find another way to create a footer for every pdf-page with some information.



  • FYI The templating engine helpers run before we pass the header to phantomjs, which in fact replaces pageNum. So there is no way to pass it to a helper function. You should use the inline javascript if you want to have some kind of a dynamic header. See it here https://jsreport.net/learn/phantom-pdf#page-numbers


Log in to reply
 

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