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
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.
Thanks for the advice! I'll definitely check out PDF.js and the image approach you mentioned, it sounds promising.