如何在动态 PDF 表单 (LiveCycle) 中将 XML 加载到数据集中?
我需要预先填写动态 PDF 的字段,以便我的用户可以对其进行编辑并提交回来。
我正在使用 Adobe ColdFusion CFPDFFORM 标签,它可以将 XML 数据加载到 PDF 中并制作新的填充 PDF。不幸的是,它还清除了
<bindItems ref="xfa.datasets.LOVFile.LOV.PreferenceLanguageList.PreferenceLanguage[*]" labelRef="$" valueRef="lic"/>
由于我无法控制 CFPDFFORM 标签的工作方式,因此我想出了一种解决方法。使用 LiveCycle Designer 进行编码,我将
这似乎可以很好地加载数据集,就像 cfpdform 弄乱它们之前的情况一样。在 loadXML() 调用之后,我可以读取数据集并获得与原始 PDF 相同的结果,其数据集标记充满 XML 数据。
form1::initialize - (JavaScript, client)
//xfa.host.messageBox("loading xml to datasets");
xfa.datasets.nodes.namedItem("LOVFile").loadXML(LOVFile_var.value,0,1);
Page1.Header.debug.rawValue = xfa.datasets.LOVFile.LOV.PreferenceLanguageList.resolveNode("PreferenceLanguage[2]").value;
问题是下拉列表仍然不起作用,它们没有可显示的项目。不知何故,他们对数据集的绑定调用不会刷新?
loadXML() 之后我还应该做些什么吗? bindItems 的 LiveCycle 参考说“列表项和引用数据之间的链接处于活动状态。对数据的任何更改都会导致列表项立即更新。”
任何帮助或指出正确的方向将不胜感激。
更新:
使用azathoth的答案,我可以使用新加载的数据集中的数据(在loadXml()调用之后)将项目添加到下拉列表中。
var oEyeColors = xfa.datasets.LOVFile.LOV.resolveNode("EyeColorList");
var numberOfNodes = oEyeColors.nodes.length;
var thisValue = "";
for (var i=0; i < numberOfNodes ; i++){
thisValue = oEyeColors.nodes.item(i).value;
if(thisValue == null){
thisValue = "";
}
xfa.resolveNode("Page1.eyeColorDropDownList").addItem(thisValue.toString());
}
这可行,但不是我正在寻找的解决方案。必须有一种 JavaScript 方法来设置下拉列表的 BindItems。
I need to pre-fill a dynamic PDF's fields so my users can edit it and submit back.
I am using Adobe ColdFusion CFPDFFORM tag that can load XML data into a PDF and make a new populated PDF. Unfortunately it also clears <xfa:datasets> tag, it completely empties it out! So all dropdownlists binded to datasets do not work. This is the code for binding one of them:
<bindItems ref="xfa.datasets.LOVFile.LOV.PreferenceLanguageList.PreferenceLanguage[*]" labelRef="$" valueRef="lic"/>
Since I have no control on how CFPDFFORM tag works, I came up with a workaround. Using LiveCycle Designer for codding, I store whatever data there is in <xfa:datasets> into a variable and load it to datasets at form::initialize.
This seems to load datasets fine, just like how they were before cfpdform messed them up. After loadXML() call , I can read the datasets and get identical results as in the original PDF with its datasets tag full of XML data.
form1::initialize - (JavaScript, client)
//xfa.host.messageBox("loading xml to datasets");
xfa.datasets.nodes.namedItem("LOVFile").loadXML(LOVFile_var.value,0,1);
Page1.Header.debug.rawValue = xfa.datasets.LOVFile.LOV.PreferenceLanguageList.resolveNode("PreferenceLanguage[2]").value;
The problem is down down lists still don't work, they have no item to show. Somehow their binding call to datasets does not refresh?
Is there anything else I should do after loadXML() ? LiveCycle reference for bindItems says "The links between the list items and the referenced data are active. Any change to the data causes an immediate update to the list items."
Any help or point to the right direction is greatly appreciated.
UPDATE:
using azathoth's answer I can add item to a dropdownlist using data from the newly loaded datasets (after loadXml() call).
var oEyeColors = xfa.datasets.LOVFile.LOV.resolveNode("EyeColorList");
var numberOfNodes = oEyeColors.nodes.length;
var thisValue = "";
for (var i=0; i < numberOfNodes ; i++){
thisValue = oEyeColors.nodes.item(i).value;
if(thisValue == null){
thisValue = "";
}
xfa.resolveNode("Page1.eyeColorDropDownList").addItem(thisValue.toString());
}
This works but is not the solution I am looking for. There must be a JavaScript way to set bindItems of a dropdown.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用此代码执行您指定的操作:
告诉我它是否适合您
I do what you specify with this code:
Tell me if it worked for you
也许这就是您正在寻找的?
使用 LiveCycle ES2.5 从后端数据源预填充动态 PDF 表单中的下拉列表
http://www.adobe.com/devnet/livecycle/articles/prepopulate-dropdown-lists.html
perhaps this is what you're looking for?
Pre-populating dropdown lists in dynamic PDF forms from a back-end data source using LiveCycle ES2.5
http://www.adobe.com/devnet/livecycle/articles/prepopulating-dropdown-lists.html