I am new to scripting in Acrobat, and I am trying to make a folder-level script to allow for the duplication of pages, among other things.
At this point, I have code that works for copying a page when the function is called, but the bizzare thing that keeps throwing errors is that when I nest that function in another, then the this.extractPages function apparently no longer exists.
Here's the relevant code:
var sourcePath = this.path;
var tempPath = app.getPath("user","temp") + "temp.pdf";
var dialogTitle = "Page to Copy";
var defaultAnswer = this.pageNum;
var nPage = app.response("Which page would you like to copy?", dialogTitle, defaultAnswer + 1) - 1;
When I call copyPage(this.pageNum), it works properly, but when I call copyPrompt(), it fails when it calls the copyPage(nPage step). Then, I get the "this.extractPages is not a function" error.
That's because when a function is called by another function, the "this"
object changes its reference and is no longer pointing to the currently
opened document. The solution is to pass it as a parameter to the nested