Good day! I want to display a .pdf file in HTML, used the following construction:

<object data="D:\Java.pdf" type="application/pdf" width="100%" height="100%" id="pdf"> <p>Alternative text - include a link <a href="D:\Java.pdf">to the PDF!</a></p> </object> 

I didn’t find information anywhere, is it possible using JavaScript to find out on which page the document is currently open? I would be grateful for any answer!

  • What is meant by "on what page"? Do you want to know the address of the page? tab in the browser? - Romanzhivo
  • @Romanzhivo No, I want to know which page in an open pdf document I'm on. For example, I want to save the last opened user page in a pdf document, so that the next time the pdf document opens on this page. Is it possible to do this? - Oleg Klimenko
  • I think it is possible, but the implementation of the pdf display in each browser is different. In Chrome, pdf is embedded via the <embed> tag, and all controls for the control (page number, etc.) are implemented via the Shadow DOM. In FF, pdf is translated into markup, and the pages are displayed as blocks of divs. I believe that a universal implementation for all browsers is hardly possible to write, but you can try for each specific browser. But if the pdf is controlled by you, then you can use the usual techniques with anchors or tracking the scroll value, for example, window.scrollY - Romanzhivo
  • @Romanzhivo I understand, thanks for the info. I will think. Maybe I'll try parsing on the server side, and throw pictures on the client side, or something like that) - Oleg Klimenko

0