Insert a page in Adobe Acrobat 11 Pro


I'm trying to create a custom java-script in Adobe Acrobat Pro 11.
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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karl Heinz KremerCommented:
Take a look at the documentation for Doc.insertPages():

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:

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

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?

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:
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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!
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:

You may want to read the document "Developing Acrobat Applications with JavaScript":

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

Have a good one!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.