I'm trying to convert programatically PDF to HTML. So far I've been using pdftohtml but our users are not happy with the results.
Here's what I need :
I'm using Ruby on Rails, but any tool working on Unix would work as I can call it from the command line. But of course a nice gem or plugin would be perfect.
I'd prefer it to be open source
It needs to be able handle images
It would be nice if there was an option to discard images if needed
It needs to be stable
It needs to return html with a layout close to the original pdf (I've tried pdftohtml and the result is not that good in a lot of cases)
you can try http://www.pdf-to-html-word.com/pdf-to-html which works really good. I paid for it after checking its functionality. You have a free ride to test it. Or else use Acrobat Pro and Save as HTML with CSS. That works too. But it's a pain in the a** to do with a bunch of files.
Can try this. I've taken a first cut at wrapping Ruby around the pdftohtml utility. Gem available here: http://gemcutter.org/gems/pdftohtmlr
Here are a couple more alternatives to pdftohtml/xpdf:
If all else fails, you could turn each page into an image (using image magick or similar) and display the images, a la http://books.google.com or http://safari.oreilly.com. It'd be a bandwidth hog, but you would get fidelity to the original.
I spent a while working on a research project that involved taking PDFs as input. What you're asking for is just a really difficult task, and no software will do it perfectly. Whereas HTML has some structure, like
<p>
, PDF is purely presentational. An HTML document will say, "this is a paragraph. This is an image." and the presentation is interpreted from that. A PDF document will essentially say: "this character should be rendered at position X,Y. this next chracter will be rendered at position..." etc. So even constructing paragraphs out of that can be hard.I was working in Java, so I don't think the specific program I used will be of much use to you. Also, I recall that some PDF generators splice an image into smaller images and display them next to each other--that was a huge pain.
Is there any possible way that you can be working with a different format, or lower your expectations? You could do the image thing that Wayne suggests, but then it's not really HTML (and it's not accessible--is that a concern for you?). That might just have to be something you live with.
After using pdftohtml for some time and being dissatisfied with the display results of the html version, I'm considering using either google apps document API or the scribd API (my favorite right now)
http://www.scribd.com/developers/api
In the end, I'll probably use pdftohtml to simply extract the text content of the pdf file and the scribd api to display the original file on the user page