2

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.

Normz
  • 271
  • 1
  • 2
  • 9
  • What issues are you having with `pdf.js`? The examples work fine and I have tried them out before. – Vivin Paliath Sep 11 '13 at 17:00
  • @VivinPaliath http://jsbin.com/pdfjs-helloworld-v2/1/edit is not showing any hello world. But I got the viewer page of the repo working after cloning. – Normz Sep 12 '13 at 07:55
  • the examples are looking to this pdfjs-dist dependency wich is not install. You have to install it first : npm i pdfjs-dist – BackdoorTech Nov 29 '22 at 16:02

1 Answers1

0

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.

Normz
  • 271
  • 1
  • 2
  • 9