prawn-labels 0.11.2 → 0.11.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/examples/hello_labels.pdf +0 -0
- data/examples/horiz_and_vert_labels.pdf +226 -0
- data/examples/horiz_and_vert_labels.rb +42 -0
- data/examples/image_labels.pdf +0 -0
- data/examples/image_labels.rb +13 -0
- data/lib/prawn/labels.rb +3 -0
- data/lib/prawn/types.yaml +14 -6
- data/prawn-labels.gemspec +1 -1
- metadata +7 -2
data/README.md
CHANGED
@@ -41,3 +41,5 @@ For a full list of examples, take a look in the `examples` folder.
|
|
41
41
|
- [Jordan Byron](http://jordanbyron.com)
|
42
42
|
- [David Speake](mailto:david@verycleverstuff.co.uk)
|
43
43
|
- [Carlo Biedenharn](mailto:cbieden@mit.edu)
|
44
|
+
- [Forrest Zeisler](https://github.com/forrest)
|
45
|
+
- [Jack Twilley](https://github.com/mathuin)
|
data/examples/hello_labels.pdf
CHANGED
Binary file
|
@@ -0,0 +1,226 @@
|
|
1
|
+
%PDF-1.3
|
2
|
+
%����
|
3
|
+
1 0 obj
|
4
|
+
<< /Creator <feff0050007200610077006e>
|
5
|
+
/Producer <feff0050007200610077006e>
|
6
|
+
>>
|
7
|
+
endobj
|
8
|
+
2 0 obj
|
9
|
+
<< /Type /Catalog
|
10
|
+
/Pages 3 0 R
|
11
|
+
>>
|
12
|
+
endobj
|
13
|
+
3 0 obj
|
14
|
+
<< /Type /Pages
|
15
|
+
/Count 1
|
16
|
+
/Kids [5 0 R]
|
17
|
+
>>
|
18
|
+
endobj
|
19
|
+
4 0 obj
|
20
|
+
<< /Length 2143
|
21
|
+
>>
|
22
|
+
stream
|
23
|
+
q
|
24
|
+
|
25
|
+
BT
|
26
|
+
15.822 797.274 Td
|
27
|
+
/F1.0 12 Tf
|
28
|
+
[<486f72> -15 <697a> 15 <6f6e74616c>] TJ
|
29
|
+
ET
|
30
|
+
|
31
|
+
|
32
|
+
BT
|
33
|
+
15.822 783.4019999999999 Td
|
34
|
+
/F1.0 12 Tf
|
35
|
+
[<4a6f7264616e>] TJ
|
36
|
+
ET
|
37
|
+
|
38
|
+
15.822 728.901 181.212 76.989 re
|
39
|
+
S
|
40
|
+
q
|
41
|
+
1.00000 0.00000 0.00000 1.00000 -598.85600 1012.92400 cm
|
42
|
+
q
|
43
|
+
-0.00000 -1.00000 1.00000 -0.00000 0.00000 0.00000 cm
|
44
|
+
q
|
45
|
+
1.00000 0.00000 0.00000 1.00000 0.00000 181.21200 cm
|
46
|
+
|
47
|
+
BT
|
48
|
+
207.034 797.274 Td
|
49
|
+
/F1.0 12 Tf
|
50
|
+
[<56> 80 <6572> -40 <746963616c>] TJ
|
51
|
+
ET
|
52
|
+
|
53
|
+
|
54
|
+
BT
|
55
|
+
207.034 783.4019999999999 Td
|
56
|
+
/F1.0 12 Tf
|
57
|
+
[<4a6f7264616e>] TJ
|
58
|
+
ET
|
59
|
+
|
60
|
+
207.034 624.678 76.989 181.212 re
|
61
|
+
S
|
62
|
+
Q
|
63
|
+
Q
|
64
|
+
Q
|
65
|
+
|
66
|
+
BT
|
67
|
+
398.246 797.274 Td
|
68
|
+
/F1.0 12 Tf
|
69
|
+
[<486f72> -15 <697a> 15 <6f6e74616c>] TJ
|
70
|
+
ET
|
71
|
+
|
72
|
+
|
73
|
+
BT
|
74
|
+
398.246 783.4019999999999 Td
|
75
|
+
/F1.0 12 Tf
|
76
|
+
[<436872> -15 <6973>] TJ
|
77
|
+
ET
|
78
|
+
|
79
|
+
398.246 728.901 181.212 76.989 re
|
80
|
+
S
|
81
|
+
q
|
82
|
+
1.00000 0.00000 0.00000 1.00000 -713.07900 744.72300 cm
|
83
|
+
q
|
84
|
+
-0.00000 -1.00000 1.00000 -0.00000 0.00000 0.00000 cm
|
85
|
+
q
|
86
|
+
1.00000 0.00000 0.00000 1.00000 0.00000 181.21200 cm
|
87
|
+
|
88
|
+
BT
|
89
|
+
15.822 720.285 Td
|
90
|
+
/F1.0 12 Tf
|
91
|
+
[<56> 80 <6572> -40 <746963616c>] TJ
|
92
|
+
ET
|
93
|
+
|
94
|
+
|
95
|
+
BT
|
96
|
+
15.822 706.4129999999999 Td
|
97
|
+
/F1.0 12 Tf
|
98
|
+
[<436872> -15 <6973>] TJ
|
99
|
+
ET
|
100
|
+
|
101
|
+
15.822 547.689 76.989 181.212 re
|
102
|
+
S
|
103
|
+
Q
|
104
|
+
Q
|
105
|
+
Q
|
106
|
+
|
107
|
+
BT
|
108
|
+
207.034 720.285 Td
|
109
|
+
/F1.0 12 Tf
|
110
|
+
[<486f72> -15 <697a> 15 <6f6e74616c>] TJ
|
111
|
+
ET
|
112
|
+
|
113
|
+
|
114
|
+
BT
|
115
|
+
207.034 706.4129999999999 Td
|
116
|
+
/F1.0 12 Tf
|
117
|
+
[<4a6f6e>] TJ
|
118
|
+
ET
|
119
|
+
|
120
|
+
207.034 651.912 181.212 76.989 re
|
121
|
+
S
|
122
|
+
q
|
123
|
+
1.00000 0.00000 0.00000 1.00000 -330.65500 1127.14700 cm
|
124
|
+
q
|
125
|
+
-0.00000 -1.00000 1.00000 -0.00000 0.00000 0.00000 cm
|
126
|
+
q
|
127
|
+
1.00000 0.00000 0.00000 1.00000 0.00000 181.21200 cm
|
128
|
+
|
129
|
+
BT
|
130
|
+
398.246 720.285 Td
|
131
|
+
/F1.0 12 Tf
|
132
|
+
[<56> 80 <6572> -40 <746963616c>] TJ
|
133
|
+
ET
|
134
|
+
|
135
|
+
|
136
|
+
BT
|
137
|
+
398.246 706.4129999999999 Td
|
138
|
+
/F1.0 12 Tf
|
139
|
+
[<4a6f6e>] TJ
|
140
|
+
ET
|
141
|
+
|
142
|
+
398.246 547.689 76.989 181.212 re
|
143
|
+
S
|
144
|
+
Q
|
145
|
+
Q
|
146
|
+
Q
|
147
|
+
|
148
|
+
BT
|
149
|
+
15.822 643.296 Td
|
150
|
+
/F1.0 12 Tf
|
151
|
+
[<486f72> -15 <697a> 15 <6f6e74616c>] TJ
|
152
|
+
ET
|
153
|
+
|
154
|
+
|
155
|
+
BT
|
156
|
+
15.822 629.424 Td
|
157
|
+
/F1.0 12 Tf
|
158
|
+
[<4d696b> 20 <65>] TJ
|
159
|
+
ET
|
160
|
+
|
161
|
+
15.822 574.923 181.212 76.989 re
|
162
|
+
S
|
163
|
+
q
|
164
|
+
1.00000 0.00000 0.00000 1.00000 -444.87800 858.94600 cm
|
165
|
+
q
|
166
|
+
-0.00000 -1.00000 1.00000 -0.00000 0.00000 0.00000 cm
|
167
|
+
q
|
168
|
+
1.00000 0.00000 0.00000 1.00000 0.00000 181.21200 cm
|
169
|
+
|
170
|
+
BT
|
171
|
+
207.034 643.296 Td
|
172
|
+
/F1.0 12 Tf
|
173
|
+
[<56> 80 <6572> -40 <746963616c>] TJ
|
174
|
+
ET
|
175
|
+
|
176
|
+
|
177
|
+
BT
|
178
|
+
207.034 629.424 Td
|
179
|
+
/F1.0 12 Tf
|
180
|
+
[<4d696b> 20 <65>] TJ
|
181
|
+
ET
|
182
|
+
|
183
|
+
207.034 470.700 76.989 181.212 re
|
184
|
+
S
|
185
|
+
Q
|
186
|
+
Q
|
187
|
+
Q
|
188
|
+
Q
|
189
|
+
|
190
|
+
endstream
|
191
|
+
endobj
|
192
|
+
5 0 obj
|
193
|
+
<< /Type /Page
|
194
|
+
/Parent 3 0 R
|
195
|
+
/MediaBox [0 0 595.28 841.89]
|
196
|
+
/Contents 4 0 R
|
197
|
+
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
198
|
+
/Font << /F1.0 6 0 R
|
199
|
+
>>
|
200
|
+
>>
|
201
|
+
>>
|
202
|
+
endobj
|
203
|
+
6 0 obj
|
204
|
+
<< /Type /Font
|
205
|
+
/Subtype /Type1
|
206
|
+
/BaseFont /Helvetica
|
207
|
+
/Encoding /WinAnsiEncoding
|
208
|
+
>>
|
209
|
+
endobj
|
210
|
+
xref
|
211
|
+
0 7
|
212
|
+
0000000000 65535 f
|
213
|
+
0000000015 00000 n
|
214
|
+
0000000109 00000 n
|
215
|
+
0000000158 00000 n
|
216
|
+
0000000215 00000 n
|
217
|
+
0000002410 00000 n
|
218
|
+
0000002590 00000 n
|
219
|
+
trailer
|
220
|
+
<< /Size 7
|
221
|
+
/Root 2 0 R
|
222
|
+
/Info 1 0 R
|
223
|
+
>>
|
224
|
+
startxref
|
225
|
+
2687
|
226
|
+
%%EOF
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "example_helper")
|
2
|
+
|
3
|
+
class Label
|
4
|
+
attr_reader :vertical_text
|
5
|
+
|
6
|
+
def initialize(name, vertical_text = false)
|
7
|
+
@name = name
|
8
|
+
@vertical_text = vertical_text
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Horizontal < Label
|
13
|
+
def initialize(name)
|
14
|
+
super(name, false)
|
15
|
+
end
|
16
|
+
|
17
|
+
def render(pdf)
|
18
|
+
pdf.text "Horizontal"
|
19
|
+
pdf.text @name
|
20
|
+
pdf.stroke_bounds
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Vertical < Label
|
25
|
+
def initialize(name)
|
26
|
+
super(name, true)
|
27
|
+
end
|
28
|
+
|
29
|
+
def render(pdf)
|
30
|
+
pdf.text "Vertical"
|
31
|
+
pdf.text @name
|
32
|
+
pdf.stroke_bounds
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
names = ["Jordan", "Chris", "Jon", "Mike"]
|
37
|
+
|
38
|
+
labels = names.map {|name| [ Horizontal.new(name), Vertical.new(name) ]}.flatten
|
39
|
+
|
40
|
+
Prawn::Labels.generate("horiz_and_vert_labels.pdf", labels, :type => "Avery5160") do |pdf, label|
|
41
|
+
label.render(pdf)
|
42
|
+
end
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require File.join(File.dirname(__FILE__), "example_helper")
|
3
|
+
|
4
|
+
fancy_names = ["Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg",
|
5
|
+
"Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg",
|
6
|
+
"Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg",
|
7
|
+
"Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg",
|
8
|
+
"Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg"]
|
9
|
+
|
10
|
+
Prawn::Labels.generate("image_labels.pdf", fancy_names, :type => "Avery5160") do |pdf, name|
|
11
|
+
pdf.text name
|
12
|
+
pdf.image open("http://jordanbyron.com/me.png")
|
13
|
+
end
|
data/lib/prawn/labels.rb
CHANGED
@@ -44,6 +44,9 @@ module Prawn
|
|
44
44
|
generate_grid @type
|
45
45
|
|
46
46
|
data.each_with_index do |record, index|
|
47
|
+
if (defined? record.vertical_text)
|
48
|
+
options.merge!(:vertical_text => record.vertical_text)
|
49
|
+
end
|
47
50
|
create_label(index, record, options) do |pdf, record|
|
48
51
|
yield pdf, record
|
49
52
|
end
|
data/lib/prawn/types.yaml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#
|
2
|
-
# prawns' basic unit is PostScript-Point
|
2
|
+
# prawns' basic unit is PostScript-Point
|
3
3
|
# 72 points per inch
|
4
4
|
#
|
5
|
+
|
5
6
|
# Avery 7160 family: Mailing labels, 63.5 x 38.1 mm, 21 per sheet
|
6
7
|
Avery7160:
|
7
8
|
paper_size: A4
|
@@ -24,7 +25,7 @@ Avery5160:
|
|
24
25
|
rows: 10
|
25
26
|
column_gutter: 10
|
26
27
|
row_gutter: 0
|
27
|
-
#Standard #10 envelope
|
28
|
+
# Standard #10 envelope
|
28
29
|
Envelope10:
|
29
30
|
paper_size: [297, 595.28]
|
30
31
|
vertical_text: true
|
@@ -34,7 +35,14 @@ Envelope10:
|
|
34
35
|
left_margin: 36
|
35
36
|
top_margin: 108
|
36
37
|
bottom_margin: 208
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
# Avery 6572
|
39
|
+
Avery6572:
|
40
|
+
paper_size: LETTER
|
41
|
+
top_margin: 36
|
42
|
+
bottom_margin: 36
|
43
|
+
left_margin: 9
|
44
|
+
right_margin: 9
|
45
|
+
columns: 3
|
46
|
+
rows: 5
|
47
|
+
column_gutter: 9
|
48
|
+
row_gutter: 0
|
data/prawn-labels.gemspec
CHANGED
metadata
CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 11
|
8
8
|
- 2
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.11.2.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Jordan Byron
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2012-01-19 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,6 +50,10 @@ files:
|
|
49
50
|
- examples/example_helper.rb
|
50
51
|
- examples/hello_labels.pdf
|
51
52
|
- examples/hello_labels.rb
|
53
|
+
- examples/horiz_and_vert_labels.pdf
|
54
|
+
- examples/horiz_and_vert_labels.rb
|
55
|
+
- examples/image_labels.pdf
|
56
|
+
- examples/image_labels.rb
|
52
57
|
- examples/shrink_to_fit.pdf
|
53
58
|
- examples/shrink_to_fit.rb
|
54
59
|
- lib/prawn/labels.rb
|