PDA

View Full Version : Embedding Javascript within a PDF


Partial
2009-06-09, 20:04
I know you can embed a swf file into a PDF document. Since this boils down to javascript basically, is it possible to run javascript out of a PDF file?

I'm looking to make an app using JQuery or one of the other developed JS libraries. I have an awesome idea, but I want to reuse the pdf scripting on the web as well, and I know how many of your hate flex/flash, so in the perfect world I use js and keep all of my potential audience happy.

Brad
2009-06-09, 20:34
JavaScript in a PDF also sounds like a bad idea. Sorry. :)

You'd be trying your users to use Adobe Reader only. No Preview.app for Mac users or any other third-party PDF readers. Also, you won't be able to use third-party JavaScript libraries like JQuery because those are built chiefly for DOM manipulation in a web browser. PDFs don't exactly work that way.

Oh, and there's also that little warning (http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=9132307) from Adobe that all users of Adobe Reader and Acrobat versions 9.x, 8.x, 7.x, and earlier on Windows, Mac, and Linux should turn off JavaScript support due to several critical security vulnerabilities. :p

Ah, Adobe's stellar track record…

Partial
2009-06-10, 00:24
Maybe I could just distribute a swf file, then? can Preview.app open a PDF file with a .swf embedded in it? I'd imagine so since they're both adobe techs.

Hmmm... PDF seems to be more familiar to the business folk that would be using my application (in theory).

Brad
2009-06-10, 08:21
Maybe I could just distribute a swf file, then? can Preview.app open a PDF file with a .swf embedded in it? I'd imagine so since they're both adobe techs.
I doubt it.

The reason Preview can open PDF files is that PDF is a core piece of Mac OS X's built-in graphics frameworks. NeXT had used PostScript (also from Adobe), but when Apple rebuilt the system for Mac OS X, a key factor in the switch to PDF was that Adobe licensed the PDF specification out for free and with few restrictions compared to the expensive PostScript license. Since then, PDF has also become an open standard (ISO 32000).

Flash, on the other hand, is still a closed, proprietary format. Only parts of the specification have been made available and until recently the whole kit had been under a very restrictive license. So, only select third parties working closely with Adobe can write a legit, working Flash interpreter.