iText 5.5无法填写表格 [英] iText 5.5 fails to fill form

查看:214
本文介绍了iText 5.5无法填写表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在使用旧的iText 2.1.7版本,但正在评估itextpdf 5.5.0。

我们在Libreoffice和Quartz(在Mac上)创建了PDF表格。


填写2.1.7(Stamper / setField等)表格时没有任何问题。

5.5.0然而表格形式在Quartz工作正常,但在Libreoffice制作的表格没有。

基本上:使用FormFlattening(false),数据显示在最终文档(以及字段)中,但是使用FormFlattening(true)时,数据(和字段)为空。


我在LibreOffice和Quartz PDF之间看到的主要区别是所有字体都嵌入在Quartz生成的PDF中。 LibreOffice无法做到这一点。
这可能是问题吗?如果是这样,为什么2.1.7工作?



提前致谢,b
Snorri

We are currently using the old iText 2.1.7 version but are evaluating itextpdf 5.5.0.
We have PDF forms created in Libreoffice and also in Quartz (on Mac).

There are no problems whatsoever when filling out the forms in 2.1.7 (Stamper/setField etc.).
With 5.5.0 however the forms made in Quartz work fine, but the forms made in Libreoffice do not.
Basically: With FormFlattening(false) the data appears in the final document(as well as the fields), but with FormFlattening(true) the data (and the fields) are empty.

The main difference I see between the LibreOffice and Quartz PDF is that all fonts are embedded in the Quartz generated PDF. This is not possible with LibreOffice.
Could this be the problem? And if so, why does 2.1.7 work?

Thanks in advance,
Snorri

推荐答案


基本上:使用FormFlattening(false),数据会出现在最终文档(以及字段)中,但是使用FormFlattening(true)时,数据(和字段)将为空。

Basically: With FormFlattening(false) the data appears in the final document(as well as the fields), but with FormFlattening(true) the data (and the fields) are empty.

如果 af 是您的 AcroFields 实例,尝试做

If af is your AcroFields instance, try to do

af.setGenerateAppearances(true);

PDF规范 ISO 32000-1 定义一个 NeedAppearances 标志,参见表218 - 交互式表单字典中的条目。如果设置为 true ,则PDF查看器知道必须为表单字段创建外观流。

The PDF specification ISO 32000-1 defines a NeedAppearances flag, cf. Table 218 – Entries in the interactive form dictionary. If it is set to true, a PDF viewer knows that it has to create appearance streams for form fields.

旧iText版本忽略该标志在表单填写期间完全且始终创建外观流。如果标志不是 true ,那么较新的iText版本会尊重该标志并仅在填写表单时创建外观流(在另一种情况下,查看器将重新创建此类外观)。

Old iText versions ignored that flag completely and always created appearance streams during form fill-in. Newer iText versions respect that flag and only create appearance streams while filling in forms if the flag is not true (in the other case the viewer will re-create such appearances anyways).

当展平表单时,iText只是将表单元素的外观嵌入到页面内容中。因此,如果在填充期间没有为某些字段创建外观流,则该值不会出现在展平文档中。

When flattening forms, iText simply embeds the appearances of the form elements into the page content. If no appearance stream was created for some field during fill-in, therefore, the value will not appear in the flattened document.

使用 setGenerateAppearances( true)您可以强制生成外观流。

Using setGenerateAppearances(true) you can enforce appearance stream generation.

这篇关于iText 5.5无法填写表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆