简体   繁体   中英

How to load PDF pages asynchronously?

I'm looking for a pdf viewer that can load a pdf asynchronously. This is a big need in our site since the PDF documents have at least 50 pages.

I've already looked into pdf.js by mozilla but I can't seem to make it work (I think the examples are broken)

Any help would greatly be appreciated! Thanks!

UPDATED: Got it working but my solution was messy. I integrated the web/viewer codebase of the pdf.js repo in my site. So whenever I need to view a pdf, I just used an iframe with a source #{pdf_viewer_path}?file=#{file_path}.

Is there a better solution than this?

NOTE: The above method does not work in a production setting. There are some js errors showing up when displaying the page. The only way I got it to work is to not precompile the js files of pdf.js.

This is an experimental solution. I just compiled the mozilla pdf.js library and integrated it with a rails engine. You can use the gem I made here: https://github.com/normancapule/pdfjs-rails-engine .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM