Merge template to one pdf
I'm stuck trying to merge multiple PDFs from a template into one PDF.
The use case is, I have one template for single device data. So one pdf for one device.
A customer want to have one pdf for all devices. The structure of the data is the same, but in an array "devices".
So I would like to reuse the same template and I thought I could merge the pdf's with pdf-utils.
Here is a simplified example: https://playground.jsreport.net/w/Fredo70/7f4aA6Iv
The problem is, the context passed to the "sub-template" is the whole context. But I would need the array element that is iterated.
The result should be really the single pdf's merges together. So the total page numbers in the footer should be 1/1 on every page. See template "desiredResult".
Is this possible? Or do I have to change my approach? With "Partials" or something else?
hi! yes it is possible, i've updated the example to produce what you want, here is the link
the trick is the script
prepare-normalTemplate-for-mergeassigned to the
normalTemplate, in which we detect that the template is getting devices data and then we modify the data to be single object that the
Wow. Great. Many many thanks !