breakdown of the most commonly used pdf libraries in rails projects,and an in depth review of prawn
example pdfs and code can be seen at prawn.heroku.com
More info at www.RailsPerformance.com
What I want you to walk away with: an understanding of the types of libraries out there, and the general strengths/weaknesses of each What prawn can and can’t do General pdf testing techniques some advanced examples and libraries
Ask them to turn in and introduce them selves to at least one new person Bring up the ‘Used it’, ‘Still Using it’ papers
PDFs are the defacto standard for reports, invoices and print friendly documents Sometimes its just easier than making the HTML print friendly The Pdf spec is quite large and complicated, you can do a lot with pdfs. One of the projects we had a Pathfinder was a PDF annotation tool for the Construction space But today I’m going to focus on the more common uses of PDF, for reports and basic print-friendly content
Not all PDFs are created equally. When I started looking into PDF generation in ruby I had some basic requirements, but pdfs can be complicated, and not all the tools will handle your needs. Let’s take a look at what’s out there
To me the libraries fall in three main categories Taking rendered html and converting or printing it as a pdf Creating a static pdf file and binding data against it Writing the code that creates the pdf components from scratch (now there are other pdf manipulation tools out there, but we’re talking about creation, not editing)
Show example of kocg form, bluebook blueprint, Mention that the library may be os specific which could affect the deployment process
May also depend on the team skills While its great to be able to reuse something you’ve already built, its pretty common to want the PDFs to have some additional element, be it security styling, etc
Get more details of these types Just because a library is commercial doesn’t mean you shouldn’t use it. Evaluate the true cost of your time In the case of HTMLDOC, its not like you are taking your full site and instantly getting pdfs out of it. Mostly you will be altering your view or creating a second view that looks the way you want it without external css. Htmlconverter – haven’t used it http:// github.com/dcu/htmlconverter/tree/master Pd4ml - http:// www.extonrails.com/?q =node/26 similar to prince, but costs less
Show example of kocg form. Now this is an example of a pdf that is better suited in the template style, but we’re going to be focusing more on regular reporting style pdfs
What other libraries are there to do this? Both pdftk and iText go beyond just template binding. They are great libraries and if you are not looking for an open source, but not necessarily pure-ruby solution, you should check them out Is pdftk tcl based? Pragmatic uses iText to insert the ‘this book licensed only to Darth Vader’ footer
You want to be mindful of the document size, because you are building so much. Not sure if there is any way to cache fragments. Prawn-to has a concept of compiled templates, but I’m not sure what that’s about
http://www.cnblogs.com/hardrock/archive/2006/07/24/458184.html RubyFpdf – php port Pdflib and rfpdf wrapper for it Does jasper reports just call out to iText? What about Flyingsaucer java How much faster is prawn than pdf writer? 40 times? And even faster on ruby 1.9
Prawn seemed to be the only one that had good test coverage
RBP will go creative-commons free in march 2010 Ruport is an interesting framework, and if you have to output reports in more than one format (csv, html, pdf) you should take a look at it. Currently the pdf side of it isn’t using prawn under the covers, but it will be soon
For positioning: you create your bounding box, then do all commands relative to that space Prawn was good for me, and depending on what you are doing, there’s a good chance it will be good for you too. Let’s take a look under the hood and see what it can do. Even if you feel that Prawn is not the right library for you, I’m hoping you’ll still get some good ideas for general pdf structure, testing and maintenance Prawn is moving fast, and there are a lot of related sub projects going on. So while it might not cover your needs right now, there’s a good chance it will soon, so keep an eye out.
Show a screen shot of the tests passing
Text – type it out and show how simple the initial syntax is Images – show just local file images first Bounding box – show the relative coordinates, and how easy it is Overflow – show how the page flow is taken care of Orientation – show landscape, portrait, and mixing the two within a document (how does that print?)
http://groups.google.com/group/pdf-writer/browse_thread/thread/5bc8de74e1a7d3c5 Groupon recently started using prawn to render the coupons, and they were able to get a good looking first cut in less than a day, and finished the final version pretty quickly They are using prawn in production to serve up over 8k pdfs a day Most of the pdfs I’ve shown you today are generated in less than 3 secods
Also mention image comparisons like bluebook
Also mention image comparisons like bluebook
http://cracklabs.com/prawnto/
Using prawn-to can help you stick to a pure MVC pattern, and not jumbling too much logic into the pdf creation
When it becomes easy to make pdfs, you can start to see creative things you never would have before
Now you might not want to call out to a 3 rd party for charts in production, but using google charts can allow you to make a quick prototype and move from concept to delivery faster
Great way to leverage your existing style concepts Make a script to parse css file and register those styles No support for div or table
Is susan Potter here? Sorry for not using twitter4r, it looks great, but I just found this one first I have this up at prawn.heroku.com, but I’m having an issue with one of the gems at the moment
Prawn-js for scripting within the pdf http://github.com/yob/prawn-js/tree/master http:// wiki.github.com /sandal/prawn/development-roadmap