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

addScript() in FDF with Reader Extensions Enabled

StealthHacker
Registered: Sep 8 2010
Posts: 3

I have some JavaScript in my FDF data for example:
/After (this.addScript("external","app.beep(0);");)
The problem is when I open the PDF after it has been [u]saved[/u] to a local machine the "external" script has not been changed.

I've tried adding a document level script which works but the Reader Extensions become disabled when I do.
/Doc [ (external) (app.beep(0);)]

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Does not look like the D.P. Story's [url=http://www.planetpdf.com/developer/article.asp?contentID=automatic_insertion_of_documen&gid=6505]Automatic Insertion of Document-Level JavaScripts[/url].

George Kaiser

StealthHacker
Registered: Sep 8 2010
Posts: 3
Thank you. I saw that site when I was doing my initial researching but it didn't help.
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
According to the documentation, addScript is not available in Reader.

I think anything you do that adds a JavaScript anywhere in a document will result in a document that no longer has Reader extension. You can change the value of form fields, however, but adding code that way is generally not a good idea.
StealthHacker
Registered: Sep 8 2010
Posts: 3
Ahh! So that's why addScript fails and modifying the /Doc scripts works.

So to expand on my situation a bit more. I've got thousands of forms on a web application which are reader extended. There is one dynamic FDF file which loads the PDFs. I'd like to be able to update the existing JavaScript in "external" document function without having to edit thousands of forms. Batch processing would still take too long since I will have to Reader Extend the forms again and upload them to the web server.

I also, would like to note that it is possible to add JavaScript which uses setAction(), to FDF on buttons without affecting Reader Extensions.
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
StealthHacker wrote:
I also, would like to note that it is possible to add JavaScript which uses setAction(), to FDF on buttons without affecting Reader Extensions.
That's interesting, I've never tried with an extended PDF before.

You've got a tough problem.