These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to execute javascript from scratch!

John_Wayne
Registered: Jul 28 2008
Posts: 10

Hello all!

I am new to Acrobat JavaScript. I have a copy of Adobe Acrobat Standard 7 running on Windows XP. Can someone please shed some light on how to open up the javascript console, write some codes and then execute them? Do I need to open a PDF file in order to activate the javascript console? What I want is just open the scripting window with my codes then execute these codes to automate some repeated tasks.

Thanks in advance for any input!
JW

My Product Information:
Acrobat Pro 7.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I don't know about Acrobat Standard, but in Acrobat Pro 7 the menu item is:

Advanced > JavaScript > DebuggerGeorge
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi John Wayne,

The JS debugger does not come built into Acrobat Standard (only Pro), but you can add it yourself. My company has a utility for adding the debugger to the free Adobe Reader but it can also be used with Acrobat Standard.
http://www.windjack.com/products/freestuff.php
(scroll to the bottom- it's titled JavaScript Console for Adobe Reader 7- instructions are provided in the ReadMe file).


After you've installed it there is an article at JavaScript Corner on using the Console Window that will be good reading for you-
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/

Hope this helps,

Dimitri
www.pdfscripting.com
www.windjack.com
John_Wayne
Registered: Jul 28 2008
Posts: 10
Thanks for your reply George.

So, I cannot run javascript with Acrobat Standard 7? Through my research, it seems that javascript can be run within Acro. Standard 7.
John_Wayne
Registered: Jul 28 2008
Posts: 10
Hello Dimitri,

Thank you for your response. I'll give it a try.
John_Wayne
Registered: Jul 28 2008
Posts: 10
Hi Dimitri,

I've installed your utility in Acrobat Reader 7. However, when I try to run a simple script to open a pdf document (i.e. app.opendoc("/c/work/test.pdf"), it seems not working. Am I missing something? Can you give me some feedback?

Thanks very much
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi John Wayne,

Are you seeing any error messages in the Console Window? What are they?

There are a couple problems with the code ( if this is exactly what you tried). It is app.openDoc, you must have parenthesis around the file name.

app.openDoc("/C/work/test.pdf")

Hope this helps,

Dimitri
WindJack Solutions
www.windjack.com
www.pdfscripting.com
John_Wayne
Registered: Jul 28 2008
Posts: 10
Hi Dimitri!

I forgot about the case-sensitive thing. It works fine now. However, when I add another line of code to insert a page into the document right after the first page:

this.insertPages({nPage: 0, cPath: "/C/Work/test1.pdf",nStart: 0});

I receive this error message:

TypeError: this.insertPages is not a function
3:Folder-Level:App:test1.js

Am I doing something wrong or placing the code in the wrong place (level)? Can you help please?

Thank,
JW