Hi, I want to fill a PDF form with a dynamic amount of fields, like if I want to create a bill on runtime where I don't know the amount of items upfront.
I the amount is bounded to an small number I could create a form with that amount of fields. If I don“t need some of them, just leave them blank. But in my case the amount of info might be 100's of items, so it has no sense to deliver to a user a PDF with 50 pages (to fit in worst case) with only the first one with data. My current strategy is to split the PDF in 3 parts. The first one with fixed data, the second one is dynamic where I add pages from a PDF template as much as data I need to place, and the third part is fixed data as the first one. So when I need to deliver a PDF to the user I merge the three parts: PDF Document = First Part + ( N x Second Part ) + Third Part This approach requires to split the document, just to be able to add as much pages as data is needed to fill. That doesn't feel clean. And a problem is that I need to touch the PDFMergerUtility.java to rename the fields using some custom pattern, for ex.: the template uses field names like "thisIsAFieldName$INDEX$itIs" and when merged I replace the $INDEX$ with the proper index number. So, I would like to check if there is a better way to approach to the need of having a not bounded amount of fields need using a template (fields repeat the names when two copies are merged). Maybe I could avoid to split the document in three parts adding pages in between two pages of a main PDF using the template. Any advice is appreciated. Regards, Jonathan.

