views:

524

answers:

1

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?

+2  A: 

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%5Fapi%5Freference.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 :(

Crimson
Thanks for replay, but is there any way to inject directly from html? How to know is document loaded? my html object tag is generating dynamically
ArsenMkrt
Thanks a lot @Crimson, I added js manually to pdf files, it works fine
ArsenMkrt