4 Replies Latest reply on Sep 18, 2008 11:08 AM by (Gregory_Mouning)

    Requesting help with using "doc.newPage" ...


      I am using Acrobat Professional 8.1.2 and I would like to add a blank page to an open document. Is there anything wrong with the following Javascript code:

      // Insert Blank Page
      app.addMenuItem({ cName: "Insert Blank Page", cParent: "Tools", cExec: "BlankPage()"});

      function BlankPage()

      Once it has been invoked, I receive the message:

      An Internal error ocurred.

      Thanks in advance for your help.

        • 1. Re: Requesting help with using "doc.newPage" ...
          gkaiseril MVP & Adobe Community Professional
          Can you run "doc.newPage();" through the JavaScript Debugging Console?

          Since the "addPage()" method is a "doc" object method it will only work within an open document using that document's document object. The default open document object is "this". Also version 7 introduced the security restriction that requires use of the "Privileged" context for this method in any context other than a batch or console operation.

          Since this method requires an open document and is not available to Reader, you might want to add the "cEnable" parameter
          • 2. Re: Requesting help with using "doc.newPage" ...
            George_Johnson MVP & Adobe Community Professional
            The newPage document method needs to be in a trusted function. Also, the doc object as you've currently coded it will be undefined. Your cExec code should be:

            cExec: "BlankPage(this);"

            and the function could look something like:

            var BlankPage = app.trustedFunction(function (doc) {



            assuming this code is placed in a folder-level JavaScript file. This isn't necessarily the best way to code this, so I'd suggest reading up on trusted functions and trust propagator functions in the Acrobat JavaScript reference for more information.

            • 3. Re: Requesting help with using "doc.newPage" ...
              Patrick Leckey Level 3
              You should also note that newPage() will not work on XFA documents even in a trusted function. You should check to see if event.target.xfa is defined before calling newPage(), and if it is perhaps show the user a dialog saying that the action cannot be performed on this document.
              • 4. Re: Requesting help with using "doc.newPage" ...
                Level 1
                Hi George,

                Thanks for supplying your code. It works for my needs. Can you refer me to an online source to learn more about trusted functions?