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

auto insert javascript into pdf?

antonumia
Registered: Nov 20 2008
Posts: 5

hi,
i have an application that indexes pdfs and works a little like searching multiple pdfs in acrobat.

I am building a new interface and i would like to auto insert document level javascript into each pdf.

does anyone know a way to do this?

command line tools would be preferable.

thanks

Anton

My Product Information:
Reader 9.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Acrobat JavaScript starting with version 6 can add scripts to document actions, setAction method, and add document level scripts, addScript method. Usually these actions are done within Acrobat as these methods are only available to Acrobat and not Reader.

You could also be able to do this using the FDF file, see [url=http://www.planetpdf.com/developer/article.asp?ContentID=automatic_insertion_of_documen&gid=6505]Automatic Insertion of Document-Level JavaScripts[/url] by D.P. Story, for more information and an example.Adobe also has an SDK for Acrobat that may conatain examples of how to add JavaScript code using other languages.

George Kaiser

antonumia
Registered: Nov 20 2008
Posts: 5
Thanks, I did look at that page (and a few others) but it seems to require an existing script to call the FDF insertion.

A bit chicken and egg without actually using acrobat.


I'm now looking to see if the AddDocJavaScript in the API is a possibility.
txstate05
Registered: Sep 29 2009
Posts: 13
did you make any progress on this? I am looking at doing the exact same thing. I think we can use this.importanfdf as a batch file with the javascript in the fdf file...i'm not familiar with the syntax of fdf with javascript. This has to be possible to add document level javascript in a batch process.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You can can set an FDF to open a known PDF and the FDF file will update the PDF automatically. This is the method used to pass back a completed PDF form submitted to a web script page.

[url=http://www.planetpdf.com/developer/article.asp?ContentID=How+to+populate+a+PDF+file&gid=6492]How to populate a PDF file's form with data from a web server[/url] by Gordon Johnson
[url=http://www.planetpdf.com/developer/article.asp?ContentID=linking_up_with_fdf&gid=6338]Linking Up with FDF] by Gordon Johnson
[url=http://www.planetpdf.com/developer/article.asp?ContentID=Web_Hosting_PDFs&gid=6526]Web Hosting PDFs[/url] by Karl De Abrew
[url=http://www.planetpdf.com/developer/article.asp?ContentID=forms_fdfgateway_a_simple_&gid=6220]FDFGateway - A simple forms data redirector[/url]Adobe has an SDK called FDF Toolkit that provides more information.

George Kaiser

txstate05
Registered: Sep 29 2009
Posts: 13
All I want to do is add Collab.showAnnotToolsWhenNoCollab = true; at the document level as a batch for thousands of PDFs on the web server so commenting is allowed in the browser. I can do this manually but obviously that is not really feasible. Is an fdf the only way to do this? If so, can you reference one fdf for all PDFs on the server?

Thanks for the quick reply... These forums do wonders for developers.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Acrobat Professional has a "Batch Processing" Option and you can "Run a JavaScript" as one of the processing options, you only need to add the script to insert a document level JavaScript.

this.addScript("CallabSet", 'Collab.showAnnotToolsWhenNoCollab = true;');
The OP was asking about a command line option.

George Kaiser

txstate05
Registered: Sep 29 2009
Posts: 13
It worked.... Thanks. I've been working on this for some time now. I owe you lunch.

Gracious