本文介绍了使用iText检测动态XFA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将预先填充的PDF / XFA表单设为只读(因为没有输入,例如文本,复选框,单选按钮等可以更改其值)。

I need to make pre-populated PDF/XFA forms read-only (as in no inputs, such as text, checkboxes, radio buttons etc. can have their values changed).

对于常规的AcroForms PDF和静态XFA表单,我可以通过调用。对于动态XFA表单,我必须将XDP的字段节点的 access 属性设置为 readOnly

For regular AcroForms PDFs and static XFA forms, I can accomplish this by calling setFormFlattening(true) on the PdfStamper instance. For dynamic XFA forms, I have to set an access attribute of the XDP's field node to be readOnly.

问题是,我如何检测表单是否动态 XFA? 不区分静态或动态XFA表单,因此无用。

The problem is, how do I detect if a form is dynamic XFA? isXfaPresent doesn't differentiate between static or dynamic XFA forms, so isn't useful.

推荐答案

iText在言论自由中是免费的,不像免费啤酒那样免费。阅读,了解我们为避免商业模式所做的商业模式的更多信息从MPL / LGPL切换到AGPL。

iText is free as in free speech, not free as in free beer. Read http://lowagie.com/bumodels for more info about the business models we've tried in order to avoid switching from the MPL/LGPL to the AGPL.

Q1:将动态XFA表格设为只读

对于最新版本的iText,这是一个明智的选择,但在您使用的过时版本中不受支持。请阅读,了解不应使用iText 4.2.0的原因(据我所知,它甚至不是官方版本;我知道,因为我负责每一个iText版本)。也许你在谈论iTextSharp。

That's a no-brainer with the most recent version of iText, but not supported in the obsolete version you're using. Please read http://lowagie.com/itext2 to find out why you shouldn't use iText 4.2.0 (which as far as I know isn't even an official release; and I know, because I'm responsible for every single iText release). Maybe you're talking about iTextSharp.

Q2:展平动态XFA表格

如果您想要展平动态XFA表单,您有两种选择:使用Adobe LiveCycle ES(这将花费你的手臂和腿),或者使用iText的XFA Worker(这是一个便宜得多的闭源产品) F / OSS iText的顶部)。鉴于此产品的成本和工时数,我认为您不会找到像免费啤酒那样免费的解决方案。我不知道有任何此类产品。

If you want to flatten a dynamic XFA form, you have two options: either use Adobe LiveCycle ES (which will cost you an arm and a leg), or use iText's XFA Worker (which is a much less expensive closed source product built on top of the F/OSS iText). Given the cost and the number of man hours that went into this product, I don't think you'll find a solution that is free as in free beer. I for one don't know of any such product.

问题3:如何确定XFA表格是否动态

我的书iText in Action - Second Edition对此进行了解释。你已经有了一半的解决方案。条件1: isXfaPresent()需要返回 true 。条件2: getFields()需要有一个空键集。请参阅此示例中的方法 readFieldnames()

This is explained in my book, "iText in Action - Second Edition." You already have half of the solution. Condition 1: isXfaPresent() needs to return true. Condition 2: getFields() needs to have an empty key set. See the method readFieldnames() in this example.

这篇关于使用iText检测动态XFA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 04:31