我犹豫是否将其发布为答案,因为它不会直接回答您的问题
但它可能会为您指明正确的方向来进行一些自助。
除非您的 PDF 文件已损坏,否则您的 3 个问题字段的唯一合理解释,它只能与它们存储在 PDF 文件中的属性有关。正如您将从下面的 Acrobat Formms 界面的摘录中看到的那样,每个字段都有大量可能的属性,我相信您应该能够识别出导致问题字段不同行为的差异.
AFORMAUTLib_TLB.Pas 为导入单元
我从 Acrobat8 的 Forms 插件生成(现在有点旧,但我
不要认为这很重要)。它的摘录显示了 Acrobat IField 的界面和
可以为 Acrobat 表单中的字段设置的无数属性/属性。
所以,在你的立场上,如果我必须使用 Reader 生成的 XML,我会做的就是编写一些代码
使用 AFORMAUTLib_TLB 中的对象转储表单字段的属性
看看我能不能找出你们三个之间有什么不同
问题领域和其余部分。使用 AFORMAUTLib_TLB 中的对象非常
直截了当 - 基本上,有一个 FormApp 对象可以让您打开
一个 Acrobat 表单并提供对其 IFields 集合的访问,其中包含
表单上定义的每个字段的 IField 实例。这一切都彻底
记录在 Adobe 网站上的 Acrobat SDK 中。
如果您花一两个小时使用 Forms 界面,我敢肯定您最终会避免使用 Reader 的 XML 输出,而只是从表单中的 IField 对象生成您自己的输出。当然,这是假设您确实需要 XML。
我想 - 但不确定(并且不想安装 Reader 来查找
out) 是 Acrobat Reader 是否具有相同的插件来处理字段。
显然,如果不是这样,那么您对这种方法就不走运了。
祝你好运!
PS:一旦你有一个感兴趣的领域的IField 接口,你可以在运行时调整它的属性和内容,所以如果你能找到导致问题的差异,它可能是非常简单
应用运行时修复。
顺便说一句,导入单元中的接口对象可能很容易变成普通的
将 PDF 文档转换成表格并可选择填写,这就是您所需要的。不过,我不确定是否已采取任何措施来禁止 Reader 中的此功能 - 如果您从事大量表单工作,那么 Acrobat 完整版的副本几乎是必不可少的。
更新:我不确定 Acrobat 8 用于导出表单数据的工具(在表单 | 管理表单数据 | 导出数据 | 保存类型:XML 下)在功能上是否与您的相同正在阅读器中使用,但对其行为的简单观察是,如果在导出数据函数时,一个字段为空,则导出的 XML 中不包含它的 XML 标记。这与该字段被清空后表单是否已保存到磁盘无关。因此,如果您的表单是这种情况,一种可能的解决方法是暂时将字段的值设置为非空值,将 PDF 导出为 XML,然后放弃更改。
// Type Lib: D:\Program Files\Adobe\Acrobat 8.0\Acrobat\plug_ins\AcroForm.api (1)
// IID\LCID: {7CD06992-50AA-11D1-B8F0-00A0C9259304}\0
// *********************************************************************//
// Interface: IField
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {673E8454-7646-11D1-B90B-00A0C9259304}
// *********************************************************************//
IField = interface(IDispatch)
['{673E8454-7646-11D1-B90B-00A0C9259304}']
function Get_Name: WideString; safecall;
function Get_Value: WideString; safecall;
procedure Set_Value(const pbstrVal: WideString); safecall;
function Get_IsHidden: WordBool; safecall;
procedure Set_IsHidden(pIsHidden: WordBool); safecall;
function Get_IsTerminal: WordBool; safecall;
function Get_Type_: WideString; safecall;
function Get_IsReadOnly: WordBool; safecall;
procedure Set_IsReadOnly(pIsRO: WordBool); safecall;
function Get_IsRequired: WordBool; safecall;
procedure Set_IsRequired(pIsReqd: WordBool); safecall;
function Get_PrintFlag: WordBool; safecall;
procedure Set_PrintFlag(pIsPrint: WordBool); safecall;
procedure SetBorderColor(const bstrColorSpace: WideString; GorRorC: Single; GorM: Single;
BorY: Single; K: Single); safecall;
procedure SetBackgroundColor(const bstrColorSpace: WideString; GorRorC: Single; GorM: Single;
BorY: Single; K: Single); safecall;
function Get_BorderWidth: Smallint; safecall;
procedure Set_BorderWidth(pVal: Smallint); safecall;
function Get_Alignment: WideString; safecall;
procedure Set_Alignment(const pVal: WideString); safecall;
function Get_CharLimit: Smallint; safecall;
procedure Set_CharLimit(pVal: Smallint); safecall;
function Get_DefaultValue: WideString; safecall;
procedure Set_DefaultValue(const pVal: WideString); safecall;
function Get_IsMultiline: WordBool; safecall;
procedure Set_IsMultiline(pVal: WordBool); safecall;
function Get_IsPassword: WordBool; safecall;
procedure Set_IsPassword(pVal: WordBool); safecall;
procedure SetExportValues(arrExportVal: OleVariant); safecall;
procedure SetJavaScriptAction(const bstrTrigger: WideString; const bstrTheScript: WideString); safecall;
procedure SetSubmitFormAction(const bstrTrigger: WideString; const bstrTheURL: WideString;
theFlags: Integer; arrFields: OleVariant); safecall;
procedure SetResetFormAction(const bstrTrigger: WideString; theFlags: Integer;
arrFields: OleVariant); safecall;
procedure SetButtonIcon(const bstrFace: WideString; const bstrFullPath: WideString;
pageNum: Smallint); safecall;
function Get_CalcOrderIndex: Smallint; safecall;
procedure Set_CalcOrderIndex(pVal: Smallint); safecall;
function Get_BorderStyle: WideString; safecall;
procedure Set_BorderStyle(const pVal: WideString); safecall;
procedure SetForegroundColor(const bstrColorSpace: WideString; GorRorC: Single; GorM: Single;
BorY: Single; K: Single); safecall;
procedure PopulateListOrComboBox(arrItems: OleVariant; arrExportVal: OleVariant); safecall;
function Get_Editable: WordBool; safecall;
procedure Set_Editable(pVal: WordBool); safecall;
function Get_Highlight: WideString; safecall;
procedure Set_Highlight(const pVal: WideString); safecall;
function Get_Style: WideString; safecall;
procedure Set_Style(const pVal: WideString); safecall;
function Get_TextFont: WideString; safecall;
procedure Set_TextFont(const pVal: WideString); safecall;
function Get_TextSize: Smallint; safecall;
procedure Set_TextSize(pVal: Smallint); safecall;
procedure SetButtonCaption(const bstrFace: WideString; const bstrCaption: WideString); safecall;
function Get_ButtonLayout: Smallint; safecall;
procedure Set_ButtonLayout(pVal: Smallint); safecall;
function Get_NoViewFlag: WordBool; safecall;
procedure Set_NoViewFlag(pVal: WordBool); safecall;
property Name: WideString read Get_Name;
property Value: WideString read Get_Value write Set_Value;
property IsHidden: WordBool read Get_IsHidden write Set_IsHidden;
property IsTerminal: WordBool read Get_IsTerminal;
property Type_: WideString read Get_Type_;
property IsReadOnly: WordBool read Get_IsReadOnly write Set_IsReadOnly;
property IsRequired: WordBool read Get_IsRequired write Set_IsRequired;
property PrintFlag: WordBool read Get_PrintFlag write Set_PrintFlag;
property BorderWidth: Smallint read Get_BorderWidth write Set_BorderWidth;
property Alignment: WideString read Get_Alignment write Set_Alignment;
property CharLimit: Smallint read Get_CharLimit write Set_CharLimit;
property DefaultValue: WideString read Get_DefaultValue write Set_DefaultValue;
property IsMultiline: WordBool read Get_IsMultiline write Set_IsMultiline;
property IsPassword: WordBool read Get_IsPassword write Set_IsPassword;
property CalcOrderIndex: Smallint read Get_CalcOrderIndex write Set_CalcOrderIndex;
property BorderStyle: WideString read Get_BorderStyle write Set_BorderStyle;
property Editable: WordBool read Get_Editable write Set_Editable;
property Highlight: WideString read Get_Highlight write Set_Highlight;
property Style: WideString read Get_Style write Set_Style;
property TextFont: WideString read Get_TextFont write Set_TextFont;
property TextSize: Smallint read Get_TextSize write Set_TextSize;
property ButtonLayout: Smallint read Get_ButtonLayout write Set_ButtonLayout;
property NoViewFlag: WordBool read Get_NoViewFlag write Set_NoViewFlag;
end;