23 ms·
Pdf2htmlEX: A PDF to HTML converter
- mgualt 14y agoVery interesting - It would be great if the author could outline his overall goals and design ideas. What are some of the constraints on the PDF in terms of page dimensions or configuration? How is the math translation done? Does it use MathML or something else? For me, the interest is that I can now go LaTeX ---> Webpage.
- agilebyte 14y agoHave you tried wiki.lyx.org/Tools/ELyXer for tex to html? I have used it on my dissertation and was mightily impressed (I am easily impressed): http://patterns.radekstepan.com/ http://patterns.radekstepan.com/
- mgualt 14y agoFrom my point of view, that's not really tex to html. That's tex markup to html. I am talking about using the latex software, whose purpose is to do typesetting. The amazing thing about this converter is that it takes the latex OUTPUT and produces html.
- coolwanglu 14y agoHello, I'm the author. MATHML is not used. PDF is rendered with only HTML/CSS, and a few JS. Please comment at github such that I can see it in time.
- mgualt 14y agoAmazing - I am attempting to install this on mac osx lion -- it is taking a lot of time because of the dependencies. With so many dependencies the probability of failure is very high. Let's hope it works. I urge you to find a way to allow people to install your software more easily. I managed to get it to install (after about an hour and a half of tinkering. However I get "Segmentation fault" when I try running it: pdf2htmlEX --debug=1 test.pdf temporary dir: /tmp/pdf2htmlEX-LY9cOv Preprocessing: .... Working: Add new temporary file: /tmp/pdf2htmlEX-LY9cOv/__css Add new temporary file: /tmp/pdf2htmlEX-LY9cOv/__pages Add new temporary file: /tmp/pdf2htmlEX-LY9cOv/p1.png Install font: (29 0) -> f1 Add new temporary file: /tmp/pdf2htmlEX-LY9cOv/f1.pfa Segmentation fault: 11
- deleted 14y ago[deleted]
- mgualt 14y agoI was able to install cmake, fontforge and libpoppler with homebrew, gcc-4.7 using https://github.com/sol-prog/gcc-4.7-binary https://github.com/sol-prog/gcc-4.7-binary
- evandrix 14y agoyou mean `poppler` instead of `libpoppler`
- tincholio 14y agosudo apt-add-repository ppa:coolwanglu/pdf2htmlex sudo apt-get update sudo apt-get install pdf2htmlex I haven't yet tried to build on mac os, but in ubuntu it was trivially simple.
- coolwanglu 14y agoThe problem is that I don't have a machine with Mac. Which version of fontforge have you installed?
- mgualt 14y agoThis is what fontforge displays when I start it up: Executable based on sources from 14:57 GMT 31-Jul-2012-D. Library based on sources from 14:57 GMT 31-Jul-2012.
- coolwanglu 14y agoI'm now trying compile with an older version. But please update fontforge if you can.
- mgualt 14y agoI think my fontforge is the current version (see above) -- please correct me if I'm wrong.
- tincholio 14y agoThis is awesome stuff! Thanks for sharing this.
- deleted 14y ago[deleted]
- antidoh 14y agoDamn, that's cool. Somewhat full circle too, in light of the many pdf printer drivers in use today.
- davidp 14y agoThis is clever, thanks for sharing. When viewing the output (using the "computer science cheat sheet") I found some differences between browsers that I thought HN readers might find interesting. These aren't primarily issues with your tool, hence posting here. - I primarily use Chrome (21) as my browser, and the cheat sheet renders very quickly. I noticed it doesn't seem to render some equations correctly (see bad operators here[1]). - FF (15.0.1) seems to render more correctly, but it is glacially slow. The whole app (chrome and all) freezes for several seconds between clicks while the document is loaded in any tab. - IE (9) renders the same page both correctly and quickly. [1] http://imageshack.us/a/img88/3754/chromeformulas.png http://imageshack.us/a/img88/3754/chromeformulas.png
- coolwanglu 14y agoThe problem happens only on Windows. For Chrome, if you zoom in, I think everything should be fine.But Chrome is lack of antialias in Windows. I'm trying to solve the problem of Firefox.
- mih 14y agoJust to add to the compatibility list, all examples render perfectly on Opera 12, albeit a bit slow.
- MartinMond 14y agoHi! This is an incredible project. I'm just curious, you mention that crocodoc has been "consulted" for this project. Did you ask them how they do their HTML5 conversion or what exactly do you mean by that? Anyway, a big Thanks for creating this project!
- coolwanglu 14y agoI meant I took a look at a HTML page generated by crocodoc. Their approach was interesting.
- fudged71 14y agoThis is fantastic! I've been using LaTeX for a while now, and nothing has really outputted HTML anywhere near this quality. I'm very impressed!
- dutchbrit 14y agoWhat about complex vectors with gradients etc?
- coolwanglu 14y agoJust go head, try and be pleased.
- neurostimulant 14y agoVery cool! This is exactly what I need. I'm going to play with it for a while.
- SeanDav 14y agoSorry for the very noob question, but how do you actually get this to run on a windows XP system? I just want to run a quick test, but it seems I have to build the project - is that correct?
- coolwanglu 14y agoYou may build it with CYGWIN.
- lectrick 14y agoStep 1: Only use Windows for games. Fire up a *nix VM, fullscreen it and get real work done in the big boy's open source developer land :)
- guilloche 14y agoAmazing, Can the same trick be used for latex=>html? It would be better than tth which is also very good.
- coolwanglu 14y agoof course you can compile latex to pdf first
- Evbn 14y agoIs it possible to reflow the page, at least in simple cases like 2-column documents? That would be awesome for mobile.
- coolwanglu 14y agoThat's beyond the scope of pdf2htmlEX.
- mgualt 14y agoIndeed, and I hope it stays out of scope forever. The idea of reflow is anathema to the idea of typesetting, as far as I can see.
- Evbn 14y agoTechnically impressive, but what systems can render HTML and JS but not PDF?
- rabidsnail 14y agoFirefox and IE on Windows.
- nilliams 14y agoThere are also various use-cases for doing this as part of a larger product. Say you need to take a customer's crappy PDFs & reformat them for display within a web app, on a public display or to send as an HTML email. You could use this tool, convert to HTML, then drop in your own CSS stylesheet to reformat it. If your customer had many of said crappy PDFs you could no-doubt automate the whole process. Needless to say I had to do something pretty similar recently, though I ended up having to ask the customer to provide better source data than the PDFs they initially sent. This tool could have been very useful at the time, hope to give it a spin soon.
- akie 14y agoI'm very impressed. Can you post some more examples online, some non-technical PDFs for example? I'm curious how well it does 'generic' PDFs (for example magazine layouts).
- coolwanglu 14y agoWhat do you suggest? I don't have one in my mind now.
- peterlai 14y agoI'm flattered the author mentions Crocodoc. Crocodoc is hiring by the way if anyone wants to hack on stuff like this full time: https://crocodoc.com/jobs/ https://crocodoc.com/jobs/
- Genmutant 14y agoHas somebody already built it for Windows and could upload the binary?
- coolwanglu 14y agoI've tried and succeeded with CYGWIN. But no idea how can I distribute the package with the dependencies.
- fpp 14y agoLooks pretty neat - saving it as html file works great, but you can't print the docs (in Chrome print to pdf only shows a scroll bar, in FF it does not properly format). Great work anyway - I'll have a deeper look.
- coolwanglu 14y agoYeah, known issue. Currently I've no idea how to fix it :(
- corry 14y agoVery cool, definitely an area where there needs to be lots of work done. What is browser compatibility like? Is IE8 supported? Edit: removed reference to HTML5/canvas, didn't see any in the source HTML.
- coolwanglu 14y agoAFAIK, IE8 doesn't support enough HTML5 stuffs, so no. IE9 should be OK
- wesley 14y agoWhat's I'd like to see is a library that can extract multi-column text into a readable format. From looking at the source of the HTML here, they're doing it with absolute positioning. Nothing wrong with that for display purposes, but I'd like to have a library that can extract text meaningfully from a multi-column PDF.
- maxerickson 14y agoThe pdftotext tool from xpdf does something like that. One option pads the output text with spaces to roughly match the layout of the pdf (the -layout option) and another option just strips the pdf formatting out (the -raw option). Depending on the structure of the pdf, one or the either may give better output (the -layout output would need some more processing).
- ChuckMcM 14y agoNeat idea, make it generate epub and it moves the pdf->e-book ball a bit further down the field. Looking at the source to this page view-source:http://coolwanglu.github.com/pdf2htmlEX/demo/geneve.html http://coolwanglu.github.com/pdf2htmlEX/demo/geneve.html it looks like you can't yet generate a font from the characters, rather it uses the 'font trick' to put images on the page. That makes the epub problem harder (which really really wants fonts not images it seems)
- coolwanglu 14y agoWhat do you mean no fonts? You can try to copy the text out, which is not possible if images are used.
- ChuckMcM 14y ago" " There I cut and pasted a quote from the document linked into this response. What do you see? I see a bunch of boxes.
- coolwanglu 14y agoIf you use HTML inspectors and remove that piece of mess, you'll find text on the html also disappear. It's the problem of font encoding, which is one of the difference between PDF and HTML. Sometimes you cannot copy the text out of PDF, but you can read correctly. I'm working on that problem. I made things like this so far because I think visual accuracy is more important.
- ChuckMcM 14y ago"It's the problem of font encoding" Yes, and that was exactly my comment. It would be really cool if the converter generated character code points for the characters on the screen. So that cutting and pasting did what you might expect. But to make that work you need to do some form of OCR on the document, figure out where the text is, and how it is composed, then you create a font which re-creates the look based on the imagery in the document and then you generate the CSS that lays down the text and decorates it with the font and re-create the visual of the PDF. (or make it an epub) If you can get it to that point, there will be huge utility for folks who want to convert paper books to e-books. Because the typical scanner will generate PDF but the typical e-book will only flow e-pub (or .mobi or proprietary formats).
- additive 14y agoIs it faster than pdftohtml?
- coolwanglu 14y agoProbably not, as font conversion is slow. pdftohtml does not extract fonts for now.
- coolwanglu 14y agoPlease try with commit f02e1d4 if any of you cannot build it on Mac