forked from prawnpdf/prawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
141 lines (88 loc) · 3.54 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
= Prawn: Fast, Nimble PDF Generation For Ruby
Prawn is a PDF writing library for Ruby designed to be tiny, fast, and nimble,
just like the majestic sea creature.
Development on this library was initially made possible thanks to
the many people who donated to the Ruby Mendicant project:
http://rubymendicant.wikidot.com
The project is currently maintained by Gregory Brown, with lots of help from
Prawn's core developers and the community.
== Quick Start
Getting started with Prawn can be as simple as:
require 'prawn'
pdf = Prawn::Document.new
pdf.text("Prawn Rocks")
pdf.render_file('prawn.pdf')
But prawn can do a lot more:
===Any page size you can think of
Prawn::Document.new('A0')
...gives you an _really_ big page.
Prawn::Document.new(:page_size => [11.32, 8.49],
:page_layout => :portrait)
...giving you a postage stamp.
{Learn more}[link:classes/Prawn/Document.html]
===Multiple Font Handling with UTF-8 Support
pdf.text("Prawn Rocks")
pdf.font("/myfont.ttf")
pdf.text("Prawn still rocks in a different font")
...allowing you to use any font you want.
{Learn more}[link:classes/Prawn/Font.html]
===Drawing graphics directly into the page
Simple shapes:
pdf.stroke do
pdf.circle_at [100,100], :radius => 25
pdf.rectangle [300,300], 100, 200
end
(note, you need to stroke the path to put "ink" there)
{Learn more}[link:classes/Prawn/Graphics.html]
===Embedding JPEG and PNG Images Natively
Reading an image directly from a file:
prawn_logo = "#{Prawn::BASEDIR}/data/images/prawn_logo.png"
pdf.image prawn_logo, :at => [50,450], :width => 450
Or reading it from an IO stream:
require "open-uri"
pdf.image open("http://prawn.majesticseacreature.com/media/prawn_logo.png")
{Learn more}[link:classes/Prawn/Images.html]
===Measurement Conversion Tools for Your Sanity
Prawn deals exclusively in PDF points... which work out to about 2.83464567mm...
don't try and do it in your head, instead, let Prawn help you:
require "prawn/measurement_extensions"
Prawn::Document.generate(:page_layout => :portrait,
:left_margin => 10.mm, # different
:right_margin => 1.cm, # units
:top_margin => 0.1.dm, # work
:bottom_margin => 0.01.m, # well
:page_size => 'A4') do
text "Prawn Rocks"
end
{Learn more}[link:classes/Prawn/Measurements.html]
===Document Security, Permissions, and Encryption
See examples/security/ for example code, such as this:
require 'prawn/security'
Prawn::Document.generate("hello_foo.pdf") do
text "Hello, world!"
encrypt_document :user_password => 'foo', :owner_password => 'bar',
:permissions => { :print_document => false }
end
This creates a document that requires the password 'foo' to be opened,
and cannot be printed without entering the owner password 'bar'.
If you want to prohibit most anyone from performing a certain activity, you can
pass :owner_password => :random to generate a probably-unguessable owner
password.
== Resources
=== Examples:
http://github.com/sandal/prawn/tree/stable/examples
=== Bug Tracker:
http://github.com/sandal/prawn/issues
=== Source Code:
http://github.com/sandal/prawn
=== Mailing List:
http://groups.google.com/group/prawn-ruby
=== IRC:
Find us in #prawn on irc.freenode.net
Gregory Brown: <sandal>
James Healy: <yob>
Brad Ediger: <bradediger>
Daniel Nelson: <bluejade>
Jonathan Greenberg: <jonsgreen>
== Notes to Developers:
See HACKING file for details on getting set up with a local build.