1

The pdf viewer from pdf.js has it built in to show the current page out of total pages:

https://mozilla.github.io/pdf.js/web/viewer.html

I have a pdf embedded on my page within an iframe.

Is it possible to use this on my page so that

<div id="counter"></div>

Is filled with the same information of currentpage / totalpages and if current page isn't possible, just a totalpages count would be a satisfactory fallback.

I tried accessing the ID of the iframe, but was getting cross-domain rejections.

1 Answers1

1

Host the viewer on your web site to not receive cross-domain rejection -- these rejections is a browser protection and you will not be able to circumvent them. Once it's on the same domain, you can access iframe's contentWindow and PDFViewerApplication object.

async5
  • 2,505
  • 1
  • 20
  • 27
  • More on the subject see the Risk Factors section at https://www.owasp.org/index.php/Cross_Frame_Scripting – async5 Feb 08 '16 at 17:19
  • Thanks for the answer! Yes I was planning on trying hosting the viewer.html as a page on my webpage and changing the references, it's not ideal due to the platform we're using - but should do the trick! –  Feb 08 '16 at 18:36