Home > Software design >  Detect scrolling in embedded PDF
Detect scrolling in embedded PDF

Time:11-02

On my page I have an embedded PDF file and I want to detect if the user scrolled at least once to make a continue button visible. I tried a few things the came to my mind, namely:

Putting the onscroll event into the HTML

<object data="flgs/EUW/EUW.pdf#zoom=38&toolbar=0&navpanes=0&scrollbar=0&view=fit" 
type="application/pdf" width="60%" height="60%" onscroll="PDF()" style="position:relative; right:20%; left:20%;">
</object>

In JS

document.getElementById('PDF').addEventListener('scroll')

$('#PDF').on('scroll')

and $('#PDF').scroll()

All three of those are different examples I tried and not in the same script at once. Is there a way I can detect whether the user scrolled in the PDF or not?

CodePudding user response:

This isn't possible unfortunately. A PDF is not a DOM element, it's rendered by PDF reader software. Every browser has its own way of rendering PDFs. In some cases the PDF might be rendered by PDF.js; in those situations you might be able to detect scrolling. But Adobe Reader, FoxIt, and other native PDF renderers don't provide that option for their customers.

  • Related