I have a loop to iterate through all of the fields and copy them from a target pdf to the current pdf.
This currently works well with manually calling the fields, and with console.log within the loop. But as soon as the field.value is updated with the field.value of the other pdf the software crashes (infinite loop?). It even crashes if the field.value is manually set for all fields. I must be missing something simple..
Here is my code:
thisDoc = this;
var docName = app.browseForDoc();
app.openDoc(docName.cPath);
var d = app.activeDocs;
var thatDoc = d[d.length-1];
var i = 0;
while (i<thatDoc.numFields){
var oldName = thatDoc.getNthFieldName(i);
var old = thatDoc.getField(oldName);
if(old.type == "text"){
if (thisDoc.getField(oldName) != null){
var cur = thisDoc.getField(oldName)
cur.value = old.valueAsString;
}
} i++;
}
thatDoc.closeDoc();
Any help would be appreciated.