Using iTextSharp to generate multiple page PDF from existing PDF Form

眉间皱痕 提交于 2020-01-05 04:58:13

问题


I have a fillable PDF form which needs to be programatically filled for each member 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.


回答1:


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.



来源:https://stackoverflow.com/questions/4951073/using-itextsharp-to-generate-multiple-page-pdf-from-existing-pdf-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!