sandal / prawn

Fast, Nimble PDF Writer for Ruby

This URL has Read+Write access

sandal (author)
Sat Jun 20 06:52:55 -0700 2009
commit  29ff7a2b4c495964fff7bd0f5fa138de12878dc1
tree    7c88acdcec8d5926eb4ed0b03f9a67602ca0dae6
parent  f67b351a490fe61a0e8c0ab243922e2f2b8a01a0
prawn / README
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 1 = Prawn: Fast, Nimble PDF Generation For Ruby
2
61d59c37 » sandal 2008-04-30 Updated readme 3 Prawn is a PDF writing library for Ruby designed to be tiny, fast, and nimble,
4 just like the majestic sea creature.
5
6 Development on this library is made possible thanks to the many people who
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 7 donated to the Ruby Mendicant project, http://rubymendicant.wikidot.com and
8 continues today with the dedicated work of the Prawn pack.
9
10 == Quick Start
11
12 Getting started with Prawn can be as simple as:
13
14 require 'prawn'
15 pdf = Prawn::Document.new
16 pdf.text("Prawn Rocks")
17 pdf.render_file('prawn.pdf')
18
19 But prawn can do a lot more:
20
21 ===Any page size you can think of
22
23 Prawn::Document.new('A0')
24
25 ...gives you an _really_ big page.
26
27 Prawn::Document.new(:size => [11.32, 8.49],
28 :page_orientation => :portrait)
29
30 ...giving you a postage stamp.
31
32 {Learn more}[link:classes/Prawn/Document.html]
33
34 ===Multiple Font Handling with UTF-8 Support
35
36 pdf.text("Prawn Rocks")
37 pdf.font("/myfont.ttf")
38 pdf.text("Prawn still rocks in a different font")
39
40 ...allowing you to use any font you want.
41
42 {Learn more}[link:classes/Prawn/Font.html]
61d59c37 » sandal 2008-04-30 Updated readme 43
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 44 ===Drawing graphics directly into the page
61d59c37 » sandal 2008-04-30 Updated readme 45
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 46 Simple shapes:
61d59c37 » sandal 2008-04-30 Updated readme 47
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 48 pdf.stroke do
49 pdf.circle_at [100,100], :radius => 25
50 pdf.rectangle [300,300], 100, 200
51 end
52
53 (note, you need to stroke the path to put "ink" there)
54
55 {Learn more}[link:classes/Prawn/Graphics.html]
56
57 ===Embedding JPEG and PNG Images Natively
58
59 Reading an image directly from a file:
60
61 prawn_logo = "#{Prawn::BASEDIR}/data/images/prawn_logo.png"
62 pdf.image prawn_logo, :at => [50,450], :width => 450
63
64 Or reading it from an IO stream:
65
66 require "open-uri"
67 pdf.image open("http://prawn.majesticseacreature.com/media/prawn_logo.png")
68
69 {Learn more}[link:classes/Prawn/Images.html]
70
71 ===Measurement Conversion Tools for Your Sanity
72
73 Prawn deals exclusively in PDF points... which work out to about 2.83464567mm...
74 don't try and do it in your head, instead, let Prawn help you:
75
6c1afa91 » sandal 2009-04-19 Amend README 76 require "prawn/measurement_extensions"
77
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 78 Prawn::Document.generate(:page_layout => :portrait,
79 :left_margin => 10.mm, # different
80 :right_margin => 1.cm, # units
81 :top_margin => 0.1.dm, # work
82 :bottom_margin => 0.01.m, # well
83 :page_size => 'A4') do
84 text "Prawn Rocks"
85 end
86
87 {Learn more}[link:classes/Prawn/Measurements.html]
88
89 == Resources
90
91 === Website:
2d601f1a » sandal 2008-08-02 Testing username 92
93 http://prawn.majesticseacreature.com
94
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 95 === Examples:
96
a729a408 » sandal 2008-12-07 Add link to examples [#138 ... 97 http://github.com/sandal/prawn/tree/master/examples
98
3454efc9 » sandal 2008-12-15 Major modifications to exam... 99 (or gem unpack prawn, if you want to run them locally)
100
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 101 === Bug Tracker / Wiki:
61d59c37 » sandal 2008-04-30 Updated readme 102
e1b96cfa » sandal 2009-04-19 Switch link to github issues 103 http://github.com/sandal/prawn/issues
61d59c37 » sandal 2008-04-30 Updated readme 104
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 105 === GitHub:
61d59c37 » sandal 2008-04-30 Updated readme 106
107 http://github.com/sandal/prawn
108
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 109 === Mailing List:
42eb3fd0 » sandal 2008-06-17 updated readme 110
111 http://groups.google.com/group/prawn-ruby
112
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 113 === IRC:
42eb3fd0 » sandal 2008-06-17 updated readme 114
cded4023 » sandal 2008-08-23 update 115 Find us in #prawn on irc.freenode.net
116 Gregory Brown: <sandal>
7b79cd10 » sandal 2008-08-23 Update readme 117 James Healy: <yob>
118
f54b2cb2 » mikel 2009-04-12 Got started with some docum... 119 == Notes to Developers:
61d59c37 » sandal 2008-04-30 Updated readme 120
6c1afa91 » sandal 2009-04-19 Amend README 121 See HACKING file for details on getting set up with a local build.