9

Hi
I am embedding pdf file to my asp.net page like this

<object data="..." type="application/pdf" width="300" height="200">
</object>

The problem is that I have created my own toolbar for pdf, and want to zoom in, out document from my toolbar image buttons. I know that I can embed JavaScript to pdf document, when creating document from scratch, but how can I embed javascript to pdf in html having only the path of that document?

Arsen Mkrtchyan
  • 49,896
  • 32
  • 148
  • 184
  • You can't access the internal object model of a PDF from script in the enclosing HTML page. They're completely different environments and unlike with Flash Adobe have not built an ExternalInterface-like API for bridging them. For what it's worth, IMO embedded PDFs are vile, a security and usability disaster area. – bobince Oct 21 '09 at 11:41

1 Answers1

7

Let the pdf document load. Once the document is ready, inject Javascript.

However, note that Javascript, as executed by your browser is different from the Javascript executed by the Adobe reader plugin for your browser. The structure is similar but the DOM is entirely different.

Further, Javascript in your HTML document cannot directly access/modify the DOM of the loaded pdf document. For that you will need to go through the reader plugin. I am sorry I have not used the reader plugin in this way. Take a look at the API:

http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf

and also read this guide:

http://www.adobe.com/devnet/acrobat/pdfs/Acro6JSGuide.pdf

These may be your best bet because very few people on SO seem to be working on Javascript for pdf. I have asked a few questions before but never got any responses :(

KJ Saxena
  • 21,452
  • 24
  • 81
  • 109