Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed javascript to existing pdf

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?

like image 985
Arsen Mkrtchyan Avatar asked Oct 21 '09 11:10

Arsen Mkrtchyan


People also ask

Can you embed in PDF?

To attach a file, go to Insert > Attach File in PDF. To embed a file, go to Insert > Embed File in PDF. Browse to and select the file that you want to insert, and click Select on the Select File dialog.

Can I iframe a PDF?

The best way I found to display a PDF was to use an iframe. iframe stands for inline frame, and it allows you to embed another HTML document within the current one. You can read more about it here.


1 Answers

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

like image 161
KJ Saxena Avatar answered Nov 15 '22 17:11

KJ Saxena