1 Reply Latest reply on Sep 30, 2011 7:07 AM by try67

    this.extractPages is not a function

    cccoccd

      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:

       

      function copyPage(page)

      {

                app.beginPriv();

       

                var sourcePath = this.path;

                var tempPath = app.getPath("user","temp") + "temp.pdf";

       

                this.extractPages({

                  nStart: page,

                  nEnd: page,

                  cPath: tempPath

                });

       

                console.println(tempPath);

       

                this.insertPages({

                           nPage: page,

                           cPath: tempPath

                 });

       

                app.endPriv();

      }

       

      app.trustedFunction(copyPage);

       

      ...

       

      function copyPrompt()

      {

                var dialogTitle = "Page to Copy";

                var defaultAnswer = this.pageNum;

                var nPage = app.response("Which page would you like to copy?", dialogTitle, defaultAnswer + 1) - 1;

                copyPage(nPage);

      }

       

      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.

       

      Thoughts?