使用iTextSharp从现有PDF表单生成多页PDF
我有一个可填写的PDF表单,需要以编程方式填写每个成员并添加到单个pdf文档中。
I have a fillable PDF form which needs to be programatically filled for each member and added to a single pdf document.
我可以使用pdfstamper来阅读现有的pdf,并更改数据,但我似乎无法弄清楚如何在同一个pdf文档中使用不同的数据创建pdfstamper的多个实例。
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.
你没有。一个PDF压模 - > 1个文件OUTPUT。你没有提供很多细节,但你的工作流程可能需要这样:
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:
对于每个PDF表格:
*用压模打开它
*填写
*打开展平
*保存(到内存或磁盘)
For Each PDF form:
* Open it with a Stamper
* Fill it in
* turn on flattening
* Save it (to memory or disk)
创建PdfCopy(或SmartCopy)
Create a PdfCopy (or SmartCopy)
对于每个中间PDF
*将其插入Pdf * Copy
For each intermediate PDF
* Insert it into Pdf*Copy
保存您的最终文档。
没有效率,但那是如何使用iText。
None too efficient, but that's how it works with iText.
PS:在将多个表格合并在一起时,您确实需要展平表单,特别是当您拥有相同表单的多个副本时。在PDF中,共享名称的字段也共享一个值。
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.