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?

1
  • 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. Commented Oct 21, 2009 at 11:41

1 Answer 1

8

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 :(

Sign up to request clarification or add additional context in comments.

2 Comments

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
Thanks a lot @Crimson, I added js manually to pdf files, it works fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.