20

What is the best solution to convert PDF documents to be viewed in the browser as HTML? The site has several PDF documents and the visitor can click on view as HTML and this should be viewed on the screen as an HTML file.

Standard website running PHP, Linux, Apache.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
ToughPal
  • 2,231
  • 5
  • 26
  • 30

4 Answers4

6

pdftohtml works fine : fast, stable but the html result is ugly at best. I have used it for quite some time for a web site that has many job resumes.

It is a good solution for extracting textual content however.

I would give the scribd API a try

or the google apps document API. GOogle does a great job a displaying and converting pdf files

Itai Sagi
  • 5,537
  • 12
  • 49
  • 73
Alexis Perrier
  • 683
  • 9
  • 13
  • 4
    For scientific papers, this looks unbelievable: https://github.com/coolwanglu/pdf2htmlEX – JDonner May 17 '14 at 19:14
  • @JDonner one caveat: the resulting HTML code is unreadable, generally uneditable, and takes megabytes of space — at least for the PDF I tested it on (2.8 MiB HTML for a 674.5 KiB PDF). This large size makes it in particular bad for serving and makes a bad experience of reading (sluggish scrolling etc.). – Ruslan Sep 11 '16 at 09:30
  • @JDonner the result looks good, but html is basically useless - it breaks words apart, encloses each part in various tags, extracts fonts for each size (of the same font) and embeds them making the file huge (as Ruslan said). you're better off converting PDF to a PNG image than using pdf2htmlEX – ierdna Aug 25 '17 at 14:34
4

Have you considered keeping the PDF data in a database and then either dynamically creating the PDF or the html page depending on what the visitors select?

Ian Jacobs
  • 5,456
  • 1
  • 23
  • 38
4

If you have command line access at your hosting provider, there is a utility called pdftohtml inside of the poppler_utils package.

http://poppler.freedesktop.org/

Looks quite easy to use, have not called it from inside of PHP, but it should work.

Kevin K
  • 151
  • 2
1

If you are prepared to call Java from PHP you could have a look at http://www.jpedal.org/html_index.php

mark stephens
  • 3,205
  • 16
  • 19