JavaScript to combine Two or more files
Yes I know this has been a major discussion in the past, but I couldn't find a proper solution, mostrly because in the replies I've read there were links which point to nowhere or expired.
Whatever, I'm trying to figure out a JS to add as action to a button that, basically merge the document from which I'm working to another document. The document is variable, in fact it depends by a value reported into a specific text field in my document. I tried to accomplish this using the following Code, but it never worked, it's just opening the other document in a different window:
var textValue = this.getField("TEXTFIELD").value;
var filePath = "G:\\Il mio Drive\\@@@@@@@@\\PASSPORT " + textValue + ".pdf";
var externalDoc = app.openDoc(filePath);
if (externalDoc != null) {
this.insertPages({
nPage: this.numPages,
cPath: filePath,
nStart: 0,
nEnd: externalDoc.numPages - 1
});
externalDoc.closeDoc(true);
} else {
app.alert("Impossibile aprire il documento esterno.");
}
Any help will be much appreciated
