How can I detect if users scroll to the bottom of a PDF displayed in the browser?

0
0
Asked By CuriousCoder93 On

Hey everyone! I'm trying to find a way to display a PDF in the browser using either an <embed> or <iframe> tag. However, my main concern is figuring out if there's a method to tell whether a user has scrolled all the way down to the bottom of the PDF. I realize I can't actually confirm if they've read it, but I just need to know if they scrolled down completely. Does anyone have suggestions for achieving this? Thanks!

1 Answer

Answered By TechSavvyUser52 On

To track the user's scroll position in a PDF, it's best to avoid using iframes. Instead, consider using PDF.js from Mozilla. This lets you render the PDF and listen for scroll events more effectively. Another option is to extract each page as an image on the server-side and then display them in a vertically scrolling div with standard DOM events. PDF.js has a lot of functionality, but it can be bulky. Rendering images might be faster and more mobile-friendly, but you'll miss out on some features like pagination controls.

CuriousCoder93 -

Thanks for the advice! I'll definitely check out PDF.js and the image approach you mentioned, it sounds promising.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.