Skip to main content
Mar 20, 2018 11:33 AM UTC
Question

extractPages

Hello !

I'm so sorry, perhaps this is a really stupid question, because I could have found the answer. I'v read so many posts about, but I can't reach what I want.

I'm using Acrobat 9 Pro. I want to extract or insert pages with a button in my pdf by using javascript. I know, it's not possible with a trigger in document scripts.

So I made a js-file named "insert_page.js" and put it into Adobe's javascript folder (C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Javascripts). The content of the script simply is:

function extract_page()

{

this.addField("Testbutton", "button", 0, [100,100, 150, 80]);

this.getField("Testbutton").fillColor=["RGB", 1, 0, 0];

this.extractPages(0, 0, "/c/Users/destinationfolder/newPage.pdf");

}

Writing this in the console: everything works fine !!! Calling from the Button, nothing happens. What ist wrong ? Please help me !!

remark: the field is only added for being sure, that the function ist really called by clicking the button. I don't really need it. Interesting is just the extractPages call.

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

Karl Heinz  Kremer
Community Expert
Community Expert
Mar 20, 2018 12:35 PM UTC

Whenever something does not work, see if you are getting any error reports in the JavaScript console. In this case, you should see a problem related to permissions being reported. See the API documentation for Doc.extractPages(), and you will find this note:

Note:If the cPath parameter is specified, this method can only be executed during a batch and console event, or through an external call (for example, OLE). See Privileged versus non-privileged context for details. The event object contains a discussion of JavaScript events.

You need to create a "privileged context" to execute this function, which meant that you need to install a folder level script on every computer that needs to run this script.

Translate
Mar 20, 2018 5:06 PM UTC

I already read this all. But obviously I don't understand, ...

Now I have:

trustedNewDoc = app.trustedFunction(function ()

{

app.beginPriv();

app.extractPages(0, 0, "/c/Users/destinationfolder/newPage.pdf");

app.endPriv();

}

I try to execute by using mouse-up action of a button with:

trustedNewDoc();

Doesn't work.

Translate
Karl Heinz  Kremer
Community Expert
Community Expert
Mar 20, 2018 5:10 PM UTC

Where do you define your trusted function? Are you getting any error message on the console?

Translate