• Welcome to Dark Bit Factory & Gravity.
 

[?] Control an embedded PDF file with JavaScript

Started by benny!, October 23, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

benny!

Hi all.

I was wondering if it is possible to control an embedded (<embed>) PDF file with JavaScript.
Like jumping to certain pages and so on ???

Any hints / links if they exists would be very interesting for me.

Thanks in advance.
benny!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Voltage

Hey Benny,

This is the JavaScript Acrobat reference, and it describes the object that you are trying to manipulate.

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

Hope this helps.

QuoteOf course, your document can change the background color setting through JavaScript by adding, for example, ââ,¬Å"app.fs.backgroundColor = color.white;ââ,¬Â? as a document level JavaScript. You can read about how to use the built-in color arrays and create your own on page 193 of the JavaScriptâ„¢ for AcrobatÃ,® API Reference.
Challenge Trophies Won:

benny!

@Voltage:
Thanks a lot for the link, mate. But it looks like this is about the in-built JavaScript of the
AcrobatReader/-document itself. What I need is JavaScript code running in the normal HTML scope
accessing the embedded acrobat document !
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Voltage

I got to a point where I can send commands to the object, but I don't know what commands to send.

After a bit of research it may be that due to security restrictions, that you may have to use the postMessage method to send a string to the PDF file.  And some javascript within the PDF file should be set up as a handler for that message.

I'm not 100% but it looks like that may be the case.

This is the code that I had.

<html>
<body>
<object id="mypdf" classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="450" height="450">
<param name="SRC" value="test.pdf">
<embed src="test.pdf" height="450" width="450">
<noembed> Your browser does not support embedded PDF files. </noembed>
</embed>
</object>
<script type="text/javascript">
function DoBoo() {
var myStrings = new Array();
myStrings[0] = "Boo";
document.mypdf.postMessage(myStrings);
}
</script>
<form action="#" method="get">
<input type="button" value="Boo" onclick="DoBoo();" />
</form>
</body>
</html>
Challenge Trophies Won: