I recently watched Ryan's railscast PDFs with Prawn and tried it on tool version tracker application's index page (Please see my previous blog - Tool Version Tracker )
It was a good experience of writing text, image, table to pdf document with clean and neat code. I was able to generate the pdf document I intended to display in less than 20-25 minutes. (installing prawn gem, prawnto plugin, understanding some API and making code changes :-)
Prawnto is a rails plugin leveraging the Prawn library to produce compiled pdf views. The plugin adds a new template handler class that will process any views with a .prawn extension. These .prawn views are evaluated as ruby code and are provided an instantiated Prawn::Document object as 'pdf'. The pdf object gives you complete access to all of prawn's capabilities.
I added the following line to my index.rhtml page :-
link_to 'PDF Format', tools_url(:pdf)
Then I created index.pdf.prawn file :-
Clicking 'PDF Format' link on index page generated inline pdf for tools as below :-
There are many things that you can do with prawnto. (http://www.cracklabs.com/prawnto/demos) I plan to try these different options.
Have a nice pdf ! :-)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment