views:

189

answers:

2

In PDF files it is quite easy to interact with form fields via the Javascript API.

Is it possible to do this (specifically showing/hiding) to arbitrary elements on a page? Say, not just form fields, but text, graphical elements, embedded images... Is there an API to interact with those?

If yes, how do I identify an object?

A: 

You can't assume that the user is using the mediocre and insecure Adobe PDF plugin.

Delan Azabani
In *my* special case, I *can* assume it. But thanks for the try.
Boldewyn
+2  A: 

Much of this depends on how "flattened" the document is. You can easily get access to links, page titles, icons, etc., but so far as I know you are not dealing with a document that parallels the HTML DOM, in which everything is able to be referenced in some way.

When a PDF is created, even from a layered application like Illustrator, parts of the document are merged (flattened) to keep the file size small. Each new presentation layer may contain what, to the original designer, may have been unrelated and/or discontiguous elements. Something up in the top right corner of a page may be merged with something seemingly unrelated in the bottom left.

It all depends on what settings the creator of the document used. Bear in mind that whoever created it may even have chosen not to convert items to PDF format at all — for example, it is allowable to import whole pages as single image files. Where elements are able to be addressed, you often have to loop through like items looking for a named element (like a page, or a title, or an icon).

Robusto
Hm, interesting. I knew a bit of these, but not all. May I ask, what the "icons" are? Is that the toolbar, or are that named entities inside the file?
Boldewyn
@Boldewin; Icons are the icons associated with buttons only. (I know, pretty lame. Sadly, so far I'm pretty unimpressed with Adobe APIs.)
Robusto