Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Generating Rich PDFs with Prawn
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Matthew Bass
August 18, 2009
95
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Generating Rich PDFs with Prawn
Leverage Prawn from your Ruby scripts to generate rich, professional-looking PDFs.
Matthew Bass
August 18, 2009
More Decks by Matthew Bass
See All by Matthew Bass
Homesteading for Freelancers
pelargir
1
73
A/B Testing for Developers
pelargir
1
73
Homesteading: The New Entrepreneurial Model
pelargir
1
62
Pragmatic Pair Programming
pelargir
3
130
Chaotic Agility
pelargir
1
84
Distance Education: An Alternative to Traditional College
pelargir
0
80
Teascript: A Homesteader's Story
pelargir
1
66
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
670
Balancing Empowerment & Direction
lara
6
1.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
We Are The Robots
honzajavorek
0
370
The browser strikes back
jonoalderson
0
1.7k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
320
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Speed Design
sergeychernyshev
33
2.1k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Leo the Paperboy
mayatellez
10
2.3k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
740
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.