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

Inserting document level javascript code in multiple pdf files as batch process

herooftheday
Registered: Feb 18 2011
Posts: 1

Hi,
 
i am searching for a solution to auto insert a specific javascript into several pdf documents.
 
I'm asking because if have hundreds of them and don't want to open them all manually...
 
The problem is, i am not good in java :-)
I guess, i have to use the batch function of acrobat pro to execute a javascript which puts another javascript (the one i need) on document level into the pdf files i choose. (?)
 
I would appreciate if some could help me with this.
 
(BTW, i'm using Acrobat Pro 8.2.6)
  
Thanks a lot.
 
Michael

My Product Information:
Acrobat Pro 8.0, Windows
MMMM4_wang
Registered: Aug 5 2010
Posts: 5
use function addScript() in your batch sequence.
n/a
try67
Expert
Registered: Oct 30 2008
Posts: 2398
As mentioned, you can use addScript(). For example:

code = "app.alert('Hello world!');";
this.addScript("HelloWorld", code);

Notice the use of double- and single-quotes.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
One can also use the JaavaScript Escape Character, "\", to insert quotation marks within a quoted string.

// define function
sCode = "function Init() { \napp.alert(\"Hello World!\");\nreturn true;\n}\n"
// add execution
sCode += "\nInit();\n";
this.addScript({cName: "Hello World", cScript: sCode});

George Kaiser