Examples of how to build PDFs in Rails with Prawn and Prawnto
From basic to advanced! (including the libraries: Prawn-format, Prawn-layout, and Prawn-grid)
PDF Generation in Rails with Prawn and Prawn-to: John McCaffrey
View more presentations from johnny_zebra.
Video of the PDF Generation presentation, including a comparison of commonly used libraries: HTMLDOC, jasper reports, iText, PrinceXML, Pdf-writer, pdftk, and oragami, as well as detailed examples of creating dynamic pdfs within an application using Prawn, Prawnto, prawn-format and other related libraries. (including an advanced demonstration of all the libraries, plus google charts api and and twitter search tool for rails)
Super-easy PDF Generation with Prawn and Prawnto by John McCaffrey from ChicagoRuby on Vimeo.
Static PDFs
From the windycityrails.org conference presentation:
-
Example of a Prawn PDF with Basic text and images
samples/image_text.pdf -
Example of a PDF with text overflow on a long eBook document
samples/carol.pdf -
Sample PDF with multiple Page layout types (landscape, portrait, LEGAL, and custom)
samples/multi-layout.pdf
Intermediate Examples
-
Using a Table layout for a structured PDF display
samples/currency.pdf -
Sample PDF with Utf8 content and international language support
samples/utf8.pdf -
Creating a Prawn PDF using Bounding boxes to manage position and layout
samples/bounding_boxes.pdf
Generating a PDF dynamically, sticking to the MVC pattern using the Prawn-to library to integrate the PDF into the view layer
-
Link to orders page (then click one, then click 'View PDF')
orders/2 orders/2.pdf
Advanced PDF building examples
-
Basic Prawn Grid layout display (showing you where the grid lines are)
samples/advanced/grid.pdf -
Demo using Prawn Grid to create mailing or address labels for Avery style print lables
samples/advanced/labels.pdf -
Creating a dynamic PDF Report with graphs and images with google charts api
samples/advanced/google_charts.pdf -
Example using Prawn-format to simplify your style and reuse your HTML and CSS styling concepts in the PDF design
samples/advanced/prawn-format.pdf
Twitter Timelines
-
Pulling everything together (prawn, prawn-layout, prawn-to, prawn-format, google chart api, twitter-search, and Heroku)
Take a look at how similar the PDF report and the HTML report are. I really didn't spend that much time on it, but they look pretty similar.
(twitter doesn't really let you get very old tweets, so as time moves on this live app wasn't able to show the tweets from the day of the conference)
/twitter_timelines/report?q=!rubyonrails will show you a timeline of tweets for the #rails hashtag (which should always have enough data)
Other Links
Replay the twitter posts from that day
Pictures from the conference courtesy of Monty Ksycki
Notes on Etherpad from the pdf presentation
Notes on Github from the pdf Conference
Rate the presentation at http://speakerrate.com
blog comments powered by Disqus