0

So, I need a way to simply implement .pdf into html5 pages. Unfortunatly, , , etc. renders messy and unpractical pdf. (And it's ugly).

I tried to use pdf.js, but it seems too big, and too heavy for what I intend to do. Plus, the lack of documentation makes it very hard to implement correctly.

What I need is:

  1. A way to show one pdf page at a time (which means, no scrolling possible).
  2. As pdf.js seems to turn each pdf page into a picture, it can't be zoomed in without the pdf becoming blurry. What I want is the scaling to update accordingly to the zoom level.
  3. The text must be selectable, word can be searched, etc.
  4. To have no ugly menu that allows to print.
  5. To be able to access to the number of the page being viewed so I can create "next" and "previous" buttons.

So, should I keep trying to set up pdf.js, or is there a better, easier option to do what I need to do, listed above?

  • https://pdfobject.com/static.html ? Does this get you any closer to your objective? – Pandelis Sep 14 '18 at 15:02
  • Alas, PDFOBJECT is not flexible at all. I even wonder why they bothered doing that. My guess is that it is an old project surpassed by adobe, microsoft, google and mozilla. –  Sep 15 '18 at 19:05

1 Answers1

0

I suggest you to bringup your software following these guidelines (in order to NOT use PDF.js...it is complex and very slow).Your software will be fast and cross-platform performance indipendent

  1. Create a page that read an input parameter (filename on local filesystem)
  2. Pass to the page the PDF you want to view
  3. On server side, read the file and convert to svg (1 per page). I can suggest you pdf2svg https://github.com/dawbarton/pdf2svg
  4. The same page has to output an HTML page containing the created SVG images formatted with you CSS rules like you want

Finally, you can start to work on toolbar,functionality, etc...

MadPapo
  • 495
  • 4
  • 13
  • 1
    Definitely that process IS the solution. SVG can be read in any browser and is a light format... Although, is pdf2svg supposed to automatically turns each page of the pdf into separated svg? I can't figure out what pdf2svg is supposed to do. The guy is talking to himself in that so called "documentation" he wrote. There are no examples to work with, no explanations... And I apparently am not alone thinking that since no one seems to use that over the web. –  Sep 15 '18 at 10:16
  • Yes pdf2svg will convert 1 file per page .you can build It and try the `--help` option or see the usage section in github .If you prefer you can implement the PDF conversion in language you prefer,this was only a suggestion. – MadPapo Sep 15 '18 at 10:20
  • 1
    And I thank you deeply for your time. I've spent hours trying to set up pdf.js. And at that point, I can confirm that this thing is an abomination. Everybody recommand that thing, but I am now pretty sure they never used it. It is slow, hard to set up and has little to no compatibility with browser other than firefox. I think that server side programmatical conversion is beyond my knowledge, unfortunately :/. Therefore, the svg, for it is kind of an hybrid format, able to be displayed like pictures, yet displaying text without that blurry effect if someone zoom in, was a great idea. –  Sep 15 '18 at 18:58