Insert a page in Adobe Acrobat 11 Pro

Hi,

I'm trying to create a custom java-script in Adobe Acrobat Pro 11.
=======================
this.insertPages(
{
nPage: this.numPages-1,
cPath: "C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\TabDoc.pdf"
});
=================
I found some examples of the code but it does not always work, once I press it, it works once but when you try again, it does not.

I want to have a one page PDF file that gets inserted after the current page that user is looking at. How can I program that so it does it continuously.  User can insert the same page into various spots in the same document. I would also need error handling, etc.

Any assistance is greatly appreciated.

Thank you.
TechMan4EverAsked:
Who is Participating?
 
Karl Heinz KremerCommented:
Take a look at the documentation for Doc.insertPages():

http://help.adobe.com/livedocs/acrobat_sdk/11/Acrobat11_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat11_HTMLHelp&file=JS_API_AcroJS.89.510.html

As you can see, the two parameters you've used have the effect of inserting a page into your current document after the last page. However, the path that is specified is wrong, you will have to use the device-independent version of your path:

"/C/Program Files (x86)/Adobe/Acrobat 11.0/Acrobat/TabDoc.pdf"

To get the current page of the document, you would use this.pageNum instead of this.numPages (which is the number of pages in the document).

To insert a page after the current page, use the following:

this.insertPages(
{
    nPage: this.pageNum,
    cPath: "/C/Program Files (x86)/Adobe/Acrobat 11.0/Acrobat/TabDoc.pdf"
});

Open in new window

0
 
TechMan4EverAuthor Commented:
That worked, thank you for your help... is there a way when you create the action and every time I have to press start script, is there a way to just have it run once I press the action?

Thanks.
0
 
Karl Heinz KremerCommented:
Ah, I did not know that you are running this in an Action. You can create a menu item in Acrobat (or a tool button) that would execute your insert page function. Take a look at the app.addMenuItem() method:

http://help.adobe.com/livedocs/acrobat_sdk/11/Acrobat11_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat11_HTMLHelp&file=JS_API_AcroJS.89.137.html
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
TechMan4EverAuthor Commented:
Thank you Karl,

I did read the article and it provides quite a bit of info. One more question, I'm new to Adobe Acrobat Pro scripting/automation but not new to programming, scripting. I'm very proficient with MS Word, etc. Can you give me a bit of quick guide, where would I put this code? Is there a start up file (line normal.dotx in word) or is there something equivalent, where I can add the code, or is this on a file level..etc.) I want to have a button, on the side menu and preferably on the top (quick tools menu). I want to have a button in both if possible that once I click on it, it will add a new page (as per previously provided code), no user interaction, just press the button, it adds a page after current page, press it again, it adds again. Simple one click kind of solution. Would you be able to provide me with some pointers?

Thank you and have a good one!
0
 
Karl Heinz KremerCommented:
You would create a "folder level" script that gets executed whenever Acrobat starts. Take a look at this blog post I wrote a while ago about where these files need to be stored: http://khkonsulting.com/2010/12/acrobat-javascripts-where-do-they-go/

You may want to read the document "Developing Acrobat Applications with JavaScript": http://help.adobe.com/livedocs/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?href=JS_API_AcroJS.88.145.html&accessible=true

You will have to expand the tree and go down the Javascript branch to find this document.
0
 
TechMan4EverAuthor Commented:
Thank you very much for all the info and you help!

Have a good one!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.