Using iTextSharp to generate multiple page PDF from existing PDF Form
I have a fillable PDF form which needs to be programatically filled for each me开发者_开发知识库mber and added to a single pdf document.
I am able to use pdfstamper to read the existing pdf, and change the data, but I cant seem to figure out how to create multiple instances of the pdfstamper with different data in the same pdf doc.
You don't. One PDF stamper->1 document OUTPUT. You didn't give a lot of detail, but your workflow will probably need to be something like this:
For Each PDF form:
* Open it with a Stamper
* Fill it in
* turn on flattening
* Save it (to memory or disk)
Create a PdfCopy (or SmartCopy)
For each intermediate PDF
* Insert it into Pdf*Copy
Save your final doc.
None too efficient, but that's how it works with iText.
PS: You really do need to flatten your forms when merging multiple forms together, PARTICULARLY when you have multiple copies of the same form. In a PDF, fields that share a name also share a value.
精彩评论