Show or hide elements in PDF via Javascript

In PDF files, it is fairly easy to interact with form fields through the Javascript API .

Can this be done (in particular, show / hide) on arbitrary elements on the page? Say, not only form fields, but text, graphic elements, embedded images ... Is there an API for interacting with them?

If so, how do I identify the object?

+6
javascript interactive pdf acrobat
source share
2 answers

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

When a PDF file is created, even from a multilevel application such as Illustrator, the parts of the document are combined (flattened) so that the file size is small. Each new level of presentation may contain what for the original designer may be unrelated and / or non-contiguous elements. Something in the upper right corner of the page can be combined with something that would seem to be unconnected in the lower left corner.

It all depends on what settings the document creator uses. Keep in mind that anyone who created it may not even have decided to convert the elements to PDF at all - for example, it is allowed to import entire pages as separate image files. When items can be addressed, you often have to iterate over items that are looking for a named item (such as a page or title or icon).

+2
source share

You cannot assume that the user is using a mediocre and insecure Adobe PDF plugin.

0
source share

All Articles