Convert HTML to PDF Ruby on Rails

Need to archive an HTML page?  Thinking that PDF might be the best way to go about doing it?  Hate the thought of dealing with PDF libraries and Ruby?  You might be in luck.  There is a web service that does PDFmyURL.  We will be doing some experimentation for a project and if it goes as expected we will release a gem in the near future.  Let us know if you have seen something better.

7 thoughts on “Convert HTML to PDF Ruby on Rails

  1. I could absolutely use this. Looking at all the
    options out there to convert from html: princeXML,
    HTMLDOC, wkhtmltopdf, none are that desireable
    primarily due to cost and/or deployment issues. I
    prefer a web service and especially since what I’m
    converting has no PII or security concerns.

  2. Would love to see this gemified! I have tried Prawn and it’s awful. I would much rather write HTML and convert it. Have you guys tested it with large ( 50+ ) pages? I found that most applications that can convert a website to PDF ( like Paparazzi! ) tend to bomb and spit out blank pages. I know the scenario is unlikely for a typical website, but I ran into this exact problem trying to generate PDFs from large HTML reports.

    • yeah and the Prawn package maintainer, Gregory Brown is quite an arrogant prick
      who is quite up himself

  3. One of my first gems was a kind of addon to
    prawn-format which I called prawn-assist.

    http://github.com/kristianmandrup/Prawn-assist

    I am planning to update it one of these days,
    converting it into a gem with a nice DSL.

    It functions by stripping out a some html tags
    which don’t have meaning for pdf generation, then
    converts certain html tags to related prawn-format
    tags and some prawn constructs. Works ok for simple
    html cases. I know there are some css gems out
    there which could be used in combination to apply
    css styling to the pdf…

  4. I am now working on a rework of prawn-assist called
    prawn-html. Feel free to join in the effort or provide
    feedback, suggestions etc 😉

  5. I’ve had a lot of success using Flying Saucer
    (https://xhtmlrenderer.dev.java.net/) with ruby-java bridge (http://rjb.rubyforge.org/). It’s damn close to acid compliant and even includes some css3 stuff for page layout. Rjb doesn’t play nicely with passenger so I had to use backgroundrb on the live servers but compared to the learning curve/limitations of itext/prawn it looks by far the easiest way to go.

Step up to the mic.

Your email address will not be published.