简体   繁体   English

使用 iText 在 PDF 文档中查找现有的 PushbuttonField

[英]Find existing PushbuttonField in PDF document using iText

I am using the Java iText library to manipulate form fields of a PDF document and have run into a simple problem.我正在使用 Java iText 库来操作 PDF 文档的表单字段并且遇到了一个简单的问题。 I am able to set properties of AcroFields that I retrieved from a PdfStamper object however what I really want to do is set an Action to an existing push button field.我可以设置从 PdfStamper object 检索到的 AcroFields 的属性,但是我真正想要做的是将 Action 设置为现有的按钮字段。

I have found countless examples of creating a new PushButton field and adding it to a document, however none that actually retrieve an existing PushbuttonField object.我发现了无数创建新 PushButton 字段并将其添加到文档的示例,但没有一个实际检索现有 PushbuttonField object。 I am sure that is the correct object because it has a setAction method where the AcroField object does not.我确信这是正确的 object 因为它有一个 setAction 方法,而 AcroField object 没有。

I am willing to accept that it is impossible because I could work around this by using Acrobat to remove the button from the template and then programatically adding it fresh everytime.我愿意接受这是不可能的,因为我可以通过使用 Acrobat 从模板中删除按钮,然后每次都以编程方式将其重新添加来解决此问题。

Further I would like to know if anybody knows of a more comprehensive location for documentation on iText.此外,我想知道是否有人知道 iText 文档的更全面位置。 Incomplete javadocs and specific code examples don't make for the best documentation.不完整的 javadocs 和特定的代码示例并不能成为最好的文档。

You need to know the name of the pushbuttonfield to retrieve it.您需要知道按钮字段的名称才能检索它。 Take a look at the example to see how to retrieve, adjust and replace.看一下示例,了解如何检索、调整和替换。

You can set actions if you have the PushbuttonField#getField()#setAction()如果您有 PushbuttonField#getField()#setAction(),则可以设置操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM