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

Batch Processing for JavaScript under Set Document Actions

felidae990
Registered: Dec 2 2008
Posts: 12

I'm using Adobe Acrobat 9 Professional and I need to use a Batch Processing routine to globally add a JavaScript associated with Set Document Actions --> Document Will Print. I found some examples of this under some older forums, but the examples didn't appear compatible with Acrobat 9. Is this possible?

Also, could I create a Batch Processing routine to globally delete JavaScripts from individual files that have Set Document Actions initiated?

Thanks in advance.

My Product Information:
Acrobat Pro Extended 9.1.1, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Why do you think the examples are not compatible with Acrobat 9?
What happens when you tried using them?

And if you want to delete an action just set it to an empty string.

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

felidae990
Registered: Dec 2 2008
Posts: 12
I modified an example I found here:
http://forums.adobe.com/message/1166300

The only thing I changed was some of the field formatting and a portion of the string entered into the date field:

// Disable auto calculate
app.calculate = false;

// Add new field to each page
for (var i = 0; i < this.numPages; i++) {// Create and format field
var aRectangle = this.getPageBox( {nPage: i} );
aRectangle[1] = aRectangle[3] + 100;
var fld = this.addField( {cName: "MyDate", cFieldType: "text", nPageNum: i, ocoords: aRectangle} ); // add field
fld.alignment = "left";
fld.textSize = 8;
fld.textColor = color.black;
fld.textFont = font.Times;
fld.readonly = true;
fld.print = true;
fld.display = display.visible;

}

// Restore auto calculate
app.calculate = true;

// add WillPrint script to populate the form field
this.setAction({cTrigger: "WillPrint",
cScript: "var fld = this.getField(\"MyDate\"); fld.value = \"Printed from controlled source on \" + util.printd(\"mm-dd-yy, HH:MM:ss\",new Date()); \r"});

The batch script will run without any errors . . . but it won’t insert the date fields or change the Set Document Actions script. Can you troubleshoot this for me?

Thanks.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Can you run the script in the JavaScript console?

George Kaiser

felidae990
Registered: Dec 2 2008
Posts: 12
I'm not sure what you mean by console. I just use the following menus:
Advanced --> Document Processing --> Batch Processing --> Edit Sequence --> Execute JavaScript, select the folder with all the PDFs I want to change, and then Run Sequence.
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi felidae990,

Copying and pasting code from forum threads sometimes can be a frustrating experience
( http://www.acrobatusers.com/blogs/thomp/copying-and-pasting-code )

The Console Window is a tool that lets you test out your code before using in a production setting and it will report errors-
http://www.acrobatusers.com/tutorials/2006/javascript_console (article)
http://www.pdfscripting.com/public/34.cfm#JSIntro (video tutorial)

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com