We have a long Adobe Dynamic XML Form PDF form that is built/coded in Adobe LiveCycle. It recently was edited and new additional pages were inserted, and now some of the form's coding is broken because some objects are on different page numbers than they previouisly were. In particular, some of the references to objects in the code are made through an xfa.resolveNode() function, which takes an argument such as "form1.page1.ObjectName". So I'll need to update those arguments to reference the proper page numbers in order to fix the code.
Manually correcting all of these references will take a very long time and be error prone. Is there a way to gather the page numbers for all objects in the original form and the new form (either in Acrobat or LiveCycle, or using Python or something), so I can easily use Excel to compare those and identify the references that I need to change?
In this particular form, all of the items are behind a single form object (form1), and on different pages from page1 to page25. So some way to either spit the object names out by page number directly from LiveCycle or Acrobat, and/or to loop through the pages in the XML (say, with Python) and collect the object names and their page numbers, is what I'm looking for.
Here's a way to display the fields of a page or another object including the page number.
In this example I have 2 pages (p1
, and p2
):
And the JavaScript opens a dialog box that contains all field paths that you can directly copy and paste in your tool of choice (p1):
(p2):
Just execute this code anywhere, e.g. place it in an initialize
event, adjust the page in the first line and the dialog will shop up.
Disclaimer: This code is by no means pretty, I just put together some pieces I had from different projects.
var page = p1;
var allFields = [];
var collectPath = function(field) {
if (field.className === "field") {
allFields.push(field.somExpression);
}
}
iterateThrough(page, collectPath, 25);
var dialog = createDialog(allFields.join("\n"));
app.execDialog(dialog);
function iterateThrough(myParentObject, doSomething, levels) {
var levelCount = 1;
var maxCount = levels;
function loopThrough(parent, doSomething, level) {
var allChildElements;
var intNumElements;
var currentElement;
var j;
allChildElements = parent.nodes;
intNumElements = allChildElements.length;
for (j = 0; j < intNumElements; j++) {
currentElement = allChildElements.item(j);
doSomething(currentElement, j, allChildElements);
if (currentElement.className === "subform") {
if (level < maxCount) {
loopThrough(currentElement, doSomething, (level + 1));
}
}
}
}
loopThrough(myParentObject, doSomething, levelCount);
}
function createDialog(msg) {
var width = 400;
var infoTextHeight = 150;
var dialog = {
description: {
name: "Test",
width: width,
height: 200,
elements: [{
type: "view",
elements: [{
type: "cluster",
align_children: "align_row",
name: "Felder",
font: "heading",
elements: [{
width: width,
height: infoTextHeight,
type: "edit_text",
multiline: true,
item_id: "NAME"
}]
},
{
type: "view",
alignment: "align_center",
elements: [{
type: "ok",
alignment: "align_center"
}]
}
]
}]
},
initialize: function (dialog) {
dialog.visible({
ERR1: false
});
dialog.load({
NAME: msg
});
},
commit: function (dialog) {
dialog.end();
}
};
return dialog;
}