News for hackers. Stuff that matters.
Re:PDFs in Pure Ruby by rubeng on Thursday January 21, 2010 @09:55PM (#1068992)
Prawn is pretty neat, but what I'd really like to see is HTML to PDF in pure Ruby. I had to use a Java library wrapped in a Ruby module to do this. Complicates my server configuration (needs the JVM) more than I'd like.
Re:PDFs in Pure Ruby by sandal on Thursday January 21, 2010 @10:36PM (#1069044)
I'm the maintainer of Prawn, and yeah, it'd be nice to see this. Jamis Buck tried this with prawn-format, but after a while we dropped support for it because it fell behind our core library and started breaking (Jamis had since moved on to other things).

In order for this to happen, what we really need is a solid box model. Since we don't have that yet, it's a very hard problem. If someone wanted to pay me to work on it full time for a year, I could get it built.

But failing that, we'll have to wait a good deal of time for this, unless someone else finds a large chunk of dedicated time for it.

Until then, Flying Saucer is the way to go if you can't afford PrinceXML price tag.

Re:PDFs in Pure Ruby by rubeng on Friday January 22, 2010 @12:43AM (#1069189)
Agreed. That's what I ended up using and it's fantastic. Great CSS support and coupled with the TagSoup parser, you can convert almost anything.
Re:PDFs in Pure Ruby by oomkiller on Thursday January 21, 2010 @10:59PM (#1069083)
Re:PDFs in Pure Ruby by rubeng on Friday January 22, 2010 @12:40AM (#1069188)
That's just a wrapper over Prince XML, I ended up writing my own wrapper over Flying Saucer: https://xhtmlrenderer.dev.java.net/
Re:PDFs in Pure Ruby by petesalty on Friday January 22, 2010 @01:02PM (#1070227)
You can try HTMLDOC (http://htmldoc.rubyforge.org/) which is a wrapper around a C library (I believe) that does exactly this. I've used it before, it's pretty fast and stable and you don't have to worry about JVM.
Re:PDFs in Pure Ruby by jmonegro on Thursday January 21, 2010 @10:03PM (#1068999)
There are many webservices out there (paid and free) that do this for you. You might want to consider that instead.
Re:PDFs in Pure Ruby by rufo on Thursday January 21, 2010 @10:03PM (#1069002)
Any details you can share? I may have a need of something similar.
Re:PDFs in Pure Ruby by sandal on Thursday January 21, 2010 @10:33PM (#1069037)
The best way to do this is FlyingSaucer via JRuby.

https://xhtmlrenderer.dev.java.net/

Re:PDFs in Pure Ruby by rubeng on Friday January 22, 2010 @12:36AM (#1069185)
I thought about that but I didn't want my entire app running within the JVM.
Re:PDFs in Pure Ruby by sandal on Friday January 22, 2010 @07:31AM (#1069554)
You probably wouldn't have to do that. Check into something like resque: http://github.com/defunkt/resque

(depends upon your needs, of course)

Re:PDFs in Pure Ruby by rubeng on Friday January 22, 2010 @12:35AM (#1069183)
Yeah, I used Flying Saucer: https://xhtmlrenderer.dev.java.net/

Only, I needed to parse plain HTML (not just XHTML) so I'm using TagSoup as the replacement parser: http://home.ccil.org/~cowan/XML/tagsoup/

This combination is awesome.