Get icon from one PDF form to another
Hi.
I made a script that import data from one PDF form to another : works fine.
I extend this script to import icons from button fields also : General error - Operation failed
(lines 11 to 13 in the script below)
Since I use an exemple copied from the "JavaScript™ for Acrobat® API Reference" I don't understand where I made a mistake.
Can you help me?
Here is my script (executed from a script embedded within the document) :
// get target document
var docCible = this;
// get source document
var cFileName = "/blablabla/myDoc.pdf";
var docSource = app.openDoc({cPath:cFileName, oDoc:this, bHidden:true});
// list source document fields
for (var i=0; i<docSource.numFields; i++) {
var oFld = docSource.getField(docSource.getNthFieldName(i));
// if the field exist in both documents
if (docCible.getField(oFld.name) != null && docSource.getField(oFld.name) != null) {
if (oFld.type == "button") {
// import icon
docCible.getField(oFld.name).buttonSetIcon(docSource.getField(oFld.name).buttonGetIcon());
}
else {
// import data
docCible.getField(oFld.name).value = docSource.getField(oFld.name).valueAsString;
}
}
}

