On 11 Aug 2010, at 17:42, Sandy wrote:

While I agree with much of what Peter said, I have had extensive
experience with generating .pdf files, including PrinceXML.  The
problems which I experienced with PrinceXML were (a) it requires an
"external" step in that you have to generate the .pdf from Prince,
based on a file which you created from your ROR application;

If you mean you have to pass on a rendered document to the prince command line utility, then yes. Generate a file... no. Whether you use Princely (http://github.com/mbleigh/princely) or the PDF helper (http://sublog.subimage.com/2007/05/29/html-css-to-pdf-using-ruby-on-rails ), there is no need to generate a file as such. The content is just passed on to the command line utility right away.

and (b)
you have to manually go into the xml file and "escape" things like "&"
signs.  Also, Prince requires that you generate a specific .css file
(no big deal, but another step).

When you're going from web to print, you'll always end up with a separate styling file, although that can just be basic stuff like overriding background colors, hiding certain elements, defining page size etc in addition to your normal view stylesheet. About the escaping, I've never had that problem, since you will be escaping the HTML in your ERB views anyway (and in Rails 3 it will be done by default). Not using the XML feature, but the HTML -> PDF feature though.

After playing with various other .pdf generation techniques, I landed
on the combination of the Prawn gem and the Prawnto plugin, which
allow a seamless integration of your ROR application and .pdf output.
As far as the issue of "headers" at the start of each page, what I do
is to simply start each individual item with a NewPage followed by a
Header partial.

We also looked into all PDF solutions out there.

We had to provide our customers with the option to generate their own PDF layouts, including vector images in the header etc. So basically what we have in our application is a module where our customers can use something they are familiar with (they're advertising agencies for the most part), i.e. HTML + CSS, with some Liquid tags sprinkled in, which we then run through the Liquid renderer and pass on to prince, the result is returned to the Rails app right away and streamed to the client, not a single "file" is generated along the way.

Prawn requires you to code the PDF into your app. Whether one likes the syntax is debatable (I for one don't :-)). It's also fairly limited in what it can do and there's tricky involved to achieve some fairly common things, like you mentioned yourself.

That said, Prince, Prawn, wicked_pdf, they are all valid options. It all depends on the requirements of your application. PrinceXML is by far the most flexible and most feature rich out of the bunch and will give you the smallest PDF, but it comes with a very hefty price tag. Wicked_pdf (which uses wkhtmltopdf) is free, but when we tried it, it was very unstable and still had a long way to go in terms of features. Prawn is nice because it doesn't use any external applications to render the PDF, but it is very limited compared to the other two imo.

I'd say: complex or large documents, especially if they have vector images, high res images or custom fonts, are a Prince thing. Reports or simple documents (possibly the invoice document the original poster talked about) are more of Prawn's territory. Wicked_pdf dangles a bit in between those two, would like to hear about people's experience with it lately.

BTW, I'm not an avid supporter of closed source software, but I have to say YesLogic has excellent support and their product is great.


Best regards

Peter De Berdt

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to