设置AcroForm值时,XFA值最初不可见 [英] XFA values initially invisible when AcroForm values are set

查看:659
本文介绍了设置AcroForm值时,XFA值最初不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动填写一个双重AcroForm/XFA PDF表单.我包括一个XFA数据集数据包,所有值都显示在Adobe Reader中.我将AcroForms条目中的V=键设置为新值,所有值都显示了其他PDF阅读器.

I want to fill out a dual AcroForm/XFA PDF form automatically. I included an XFA dataset packet and all values showed up in Adobe Reader. I set the V= key in AcroForms entries to the new value and all values showed up alternative PDF readers.

但是,当我在Adobe Reader中使用XFA和AcroForm V=条目打开PDF时,仅可见当前选定的文本字段的值:

However, when I open the PDF with XFA and AcroForm V= entries in Adobe Reader, only the value of the text field that is currently selected is visible:

我在

I cannot find any mention in the PDF specification of a special flag to set when AcroForms and XFA are present. I hypothesized that the order of the XFA and Field keys may be important, but that's not it either.

如何更改我的PDF文件,以使这些值在Adobe中可见启动时的阅读器,以及仅支持AcroForms而不支持XFA的PDF阅读器中的?

How can I change my PDF file so that the values are visible in Adobe Reader on startup, and in PDF readers which only support AcroForms and not XFA?

推荐答案

有2个问题需要回答:

  1. 为什么在选择字段时Adobe Reader仅显示字段值?
  2. 如何确定是否使用AcroForm或XFA?

1.显示的字段值

在某些情况下,Adobe Reader/Acrobat将根据是否选择显示不同的表单字段.这对于具有定义的外观的字段是典型的,该字段不同于Reader/Acrobat根据其值(可能还有某些外观设置)呈现该字段的方式.

1. Displayed field values

In some cases Adobe Reader/Acrobat will display a form field differently depending on whether it's selected or not. This is typical for a field that has a defined appearance that is different from how Reader/Acrobat would render the field based on its value (and possibly some appearance settings).

未选择该字段时,将显示定义的外观.选中该字段后,将显示Reader/Acrobat如何呈现它的预览.

When the field is not selected, the defined appearance will be shown. When the field is selected, a preview of how Reader/Acrobat would render it is shown.

一些背景:

表单字段由称为 field字典的逻辑部分(字段名称,字段值,...)和称为 widget注释.小部件注释可以选择包含 AP 条目,其中包含定义其可视化效果的外观流. cf. PDF规范1.7 ,表8.15:

A form field consists of a logical part (field name, field value, ...), called the field dictionary, and a visualization part, called the widget annotation. The widget annotation can optionally contain an AP entry, containing the appearance streams that define its visualization. Cf. PDF Specification, 1.7, Table 8.15:

AP -词典-一种外观词典,用于指定如何在页面上直观显示注释.

AP - dictionary - An appearance dictionary specifying how the annotation is presented visually on the page.

在示例PDF中,没有 AP 条目,即空白可视化.这是所有字段显示的内容.选择字段时,您会根据字段值看到Reader/Acrobat的预览.

In the sample PDF there are no AP entries, i.e. blank visualizations. This is what's displayed for all the fields. When selecting a field, you see Reader/Acrobat's preview, based on the field value.

您可以通过使用Reader/Acrobat手动更改字段值来验证这一点.在这种情况下,将生成并保存一个新的外观.现在,无论是否选择该字段,该字段都将以相同的方式显示.

You can verify this by changing a field value manually with Reader/Acrobat. In that case, a new appearance will be generated and saved. That field will now be displayed in the same way, regardless of it being selected or not.

两个选项可防止在Reader/Acrobat中出现这些空白"字段:

Two options to prevent these "blank" fields in Reader/Acrobat:

  • 为所有表单字段生成外观流.我已经在一个字段中完成了此操作(只需使用iText来重新设置其值,该iText就会自动生成外观流).

  • Generate appearance streams for all form fields. I have done this for one field (by simply re-setting its value using iText, which automatically generates an appearance stream).

结果:

内部PDF结构:

AcroForm 词典中的 NeedAppearances 条目设置为true. cf. PDF规范1.7 ,表8.67:

Set the NeedAppearances entry in the AcroForm dictionary to true. Cf. PDF Specification, 1.7, Table 8.67:

NeedAppearances -布尔值-一个标志,用于指定是否为文档中的所有小部件注释构造外观流和外观字典

NeedAppearances - boolean - A flag specifying whether to construct appearance streams and appearance dictionaries for all widget annotations in the document

这将触发查看器生成所有外观:

This will trigger the viewer to generate all the appearances:

通常,具有XFA功能的查看器将显示XFA表单.没有XFA支持的查看器将使用AcroForm.您可以通过为相应的AcroForm和XFA字段设置不同的值来验证这一点.结果是,左侧的Chrome内置PDF查看器(不支持XFA),右侧的Acrobat:

In general, a XFA capable viewer will display the XFA form. A viewer without XFA support will use the AcroForm. You can verify this by setting different values for corresponding AcroForm and XFA fields. This is the result, Chrome's built-in PDF viewer on the left (no XFA support), Acrobat on the right:

知道Reader/Acrobat使用的是XFA表单,为什么我们仍然看到空白字段(参见问题1)?

Knowing that Reader/Acrobat is using the XFA form, why did we still see the blank fields (cf question 1)?

似乎,当XFA字段及其对应的AcroForm字段的值相同时,Reader/Acrobat也将使用AcroForm中的一些信息.它的外观信息.当XFA值不同于AcroForm值时,AcroForm字段似乎被完全忽略.

It seems that, when the values of an XFA field and its corresponding AcroForm field are the same, Reader/Acrobat also uses some information from the AcroForm, a.o. its appearance information. When the XFA value is different from the AcroForm value, the AcroForm field seems to be ignored completely.

TL; DR将 NeedAppearances 设置为true以解决空白字段.不支持XFA的查看器将自动退回到AcroForm.

TL;DR Set NeedAppearances to true to solve blank fields. XFA-incapable viewers will fall back to AcroForm automatically.

(我的测试基于Adobe Acrobat X.)

(My tests are based on Adobe Acrobat X.)

这篇关于设置AcroForm值时,XFA值最初不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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