Author Topic: [?] Control an embedded PDF file with JavaScript  (Read 6684 times)

0 Members and 1 Guest are viewing this topic.

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
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:

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: [?] Control an embedded PDF file with JavaScript
« Reply #1 on: November 14, 2007 »
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.

Quote
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [?] Control an embedded PDF file with JavaScript
« Reply #2 on: November 14, 2007 »
@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:

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: [?] Control an embedded PDF file with JavaScript
« Reply #3 on: November 15, 2007 »
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.

Code: [Select]
<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: