Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Generating Rich PDFs with Prawn
Search
Matthew Bass
August 18, 2009
0
70
Generating Rich PDFs with Prawn
Leverage Prawn from your Ruby scripts to generate rich, professional-looking PDFs.
Matthew Bass
August 18, 2009
Tweet
Share
More Decks by Matthew Bass
See All by Matthew Bass
Homesteading for Freelancers
pelargir
1
51
A/B Testing for Developers
pelargir
1
59
Homesteading: The New Entrepreneurial Model
pelargir
1
54
Pragmatic Pair Programming
pelargir
3
100
Chaotic Agility
pelargir
1
61
Distance Education: An Alternative to Traditional College
pelargir
0
59
Teascript: A Homesteader's Story
pelargir
1
39
Featured
See All Featured
Building Adaptive Systems
keathley
44
2.9k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
60
37k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
680
How to make the Groovebox
asonas
2
1.8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
29
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
1.9k
Raft: Consensus for Rubyists
vanstee
141
7.2k
How Software Deployment tools have changed in the past 20 years
geshan
0
29k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.3k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1k
Transcript
Generating Rich PDFs with Prawn Matthew Bass
Should my app even be generating PDFs?
The alternatives... • PDF::Writer http://ruby-pdf.rubyforge.org/pdf-writer/ • Ruby FPDF http://zeropluszero.com/software/fpdf/ •
And... that’s it?
PDF::Writer • The best choice for a long time... •
Much slower than Prawn • Markup isn’t as nice
• Port of FPDF written in PHP • Nice logo?
• ???
Prawn gives you PDF goodness... • Fast • Clean syntax*
• Image embedding, tables, etc. • Full UTF-8 support • PNGs with alpha transparencies
Caveat... http://prawn.majesticseacreature.com
History... • Founded April, 2008 by Gregory Brown • ...the
guy who brought us Ruport • Ruby Mendicant project
The gems... prawn-core http://prawn.majesticseacreature.com prawn-layout http://github.com/sandal/prawn-layout/ prawn-format http://github.com/sandal/prawn-format/
Installation Options # Clone from the repository git clone git://github.com/sandal/prawn.git
# Install the gem directly sudo gem install prawn Keepin’ it simple...
Kickin’ it up a notch... Installation Options rake gems:install rake
gems:unpack # optional
Or configure your Rails project for the latest release of
prawn-core and extensions... Installation Options rake gems:install rake gems:unpack # optional
What can it do?
Tables... Exact positioning... Italic, bold, etc... Drawing...
Image embedding... Background colors... UTF-8...
Rails integration...
Inline HTML formatting with prawn-format Speed observations... it’s faster!
Code Examples
Text...
Positioning...
Drawing...
Colors...
Embedding images...
prawn-layout Adds support for tables, grid layouts, etc.
prawn-format Adds support for inline formatting w/HTML tags
prawnto some_controller.rb default.prawn Tasty with Rails! Use helpers, instance vars,
etc. in your views
Bugs & Gotchas • Adobe Reader incompatibilities • Occasional UTF-8
errors • Spotty error handling • prawn-format doesn’t like some chars (gt, lt)
Background Processing Can’t beat delayed_job for simplicity... http://github.com/tobi/delayed_job/ # Run
queued jobs rake jobs:work
Conclusion!
Matthew Bass matthewbass.com ©2009 Adeptware, Inc.