• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

extractPages

New Here ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

543

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

If you look in the JS console you'll see an error message that starts like this:

TypeError: app.extractPages is not a function

That should give you a good hint as to what you're doing wrong... Think about it: How can the application extract pages? It's the document that should be doing it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

LATEST

Hallelujah !!

trustedNewDoc = app.trustedFunction( function ()

{

app.beginPriv();

this.extractPages({nStart:1, cPath: "/c/Users/destinationfolder/newPage.pdf"});

app.endPriv();

})

and in the MouseUp action:

trustedNewDoc();

THIS WORKS !!

THANKS FOR HELP

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines