Reputation: 3
I am using this construction for view the .pdf file:
<object id="yeah" data="D:\Java.pdf" type="application/pdf" width="100%" height="100%">
<p>Alternative text - include a link <a href="D:\Java.pdf">to the PDF!</a></p>
</object>
I haven't found any information:
1. Can I get number of current viewed page in document by using JS?
2. Can I open document on page which I want?
Thanks for any reply.
Upvotes: 0
Views: 3860
Reputation: 77528
You posted two questions:
#1: Can I get the page number of the current page that is viewed by using JS:
No, it is very hard to establish a communication between the JavaScript in your browser and the JavaScript in your PDF viewer. See for instance PDF hostContainer callback, but please understand that what I describe in that answer doesn't work anymore in most browsers, and that PDF viewers such as Preview, Chrome PDF Viewer, pdf.js,... don't support that functionality.
#2: Can I open a PDF document on a specific page?
Yes, you can do so by composing the link as described in the PDF Open Parameters document by Adobe. This is also explained in the answers to this question: Open a pdf file programmatically at a named destination
This example was copy/pasted from Adobe's document:
http://example.org/doc.pdf#pagemode=bookmarks&page=2
As you can see, you need to add #
after the URL and pass a page
parameter of which the value is the page number. You'll find many other examples in that document, but once more: be aware that this is the behavior of Adobe Reader. Other viewers may ignore those parameters.
Upvotes: 1