prawn-labels 0.11.2.2 → 0.11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -10,31 +10,71 @@ $ gem install prawn-labels
10
10
 
11
11
  ## Usage
12
12
 
13
+ We've tried to make generating labels as simple as possible with Prawn::Labels.
14
+ If you have an object which responds to `each`, then you're in business.
15
+
16
+ ### Create and save a PDF file
17
+
13
18
  ```ruby
14
19
  require 'prawn/labels'
15
20
 
16
21
  names = ["Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg"]
17
22
 
18
- # Create and save a PDF file
19
23
  Prawn::Labels.generate("names.pdf", names, :type => "Avery5160") do |pdf, name|
20
24
  pdf.text name
21
25
  end
26
+ ```
27
+
28
+ This creates a document with a name from the names array in each label. The labels will be formatted for Avery 5160 labels. Formats are defined in the `prawn/labels/types.yaml` file, or by [loading a custom hash or yaml file](#custom-label-types)
29
+
30
+ For a full list of examples, take a look in the `examples` folder.
31
+
32
+ ### Render a PDF file and send to browser
22
33
 
23
- # Render a PDF file and send to browser
34
+ ```ruby
24
35
  labels = Prawn::Labels.render(names, :type => "Avery5160") do |pdf, name|
25
36
  pdf.text name
26
37
  end
38
+
27
39
  send_data labels, :filename => "names.pdf", :type => "application/pdf"
40
+ ```
28
41
 
29
- # Scale text to fit label
30
- Prawn::Labels.generate("names.pdf", names, :type => "Avery5160", :shrink_to_fit => true) do |pdf, name|
42
+ ### Scale text to fit label
43
+
44
+ ```ruby
45
+ Prawn::Labels.generate( "names.pdf", names, :type => "Avery5160",
46
+ :shrink_to_fit => true) do |pdf, name|
31
47
  pdf.text name
32
48
  end
33
49
  ```
34
50
 
35
- This creates a document with a name from the names array in each label. The labels will be formatted for Avery 5160 labels. Formats are defined in the prawn/labels/types.yaml file.
51
+ ### Custom label types
36
52
 
37
- For a full list of examples, take a look in the `examples` folder.
53
+ If the label type you need to use isn't defined in `prawn/labels/types.yaml`
54
+ file, you can define and load your own.
55
+
56
+ ```ruby
57
+ Prawn::Labels.types = '/path/to/custom/types.yaml'
58
+
59
+ Prawn::Labels.generate("names.pdf", names, :type => "Custom123") do |pdf, name|
60
+ pdf.text name
61
+ end
62
+ ```
63
+
64
+ or using a hash:
65
+
66
+ ```ruby
67
+ Prawn::Labels.types = {
68
+ "QuarterSheet" => {
69
+ "paper_size" => "A4",
70
+ "columns" => 2,
71
+ "rows" => 2
72
+ }}
73
+
74
+ Prawn::Labels.generate("names.pdf", names, :type => "QuarterSheet") do |pdf, name|
75
+ pdf.text name
76
+ end
77
+ ```
38
78
 
39
79
  ## Contributors
40
80
 
@@ -43,3 +83,4 @@ For a full list of examples, take a look in the `examples` folder.
43
83
  - [Carlo Biedenharn](mailto:cbieden@mit.edu)
44
84
  - [Forrest Zeisler](https://github.com/forrest)
45
85
  - [Jack Twilley](https://github.com/mathuin)
86
+ - [Ori Pekelman](https://github.com/OriPekelman)
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), "example_helper")
2
+
3
+ fancy_names = ["Jordan", "Chris", "Jon", "Mike", "Kelly", "Bob", "Greg",
4
+ "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
+
9
+ #define a custom label type
10
+ Prawn::Labels.types = {
11
+ "Agipa119461" => {
12
+ "paper_size" => "A4",
13
+ "top_margin" => 36.57,
14
+ "bottom_margin" => 0,
15
+ "left_margin" => 20.551,
16
+ "right_margin" => 20.551,
17
+ "columns" => 3,
18
+ "rows" => 8,
19
+ "column_gutter" => 7.087,
20
+ "row_gutter" => 0
21
+ }}
22
+
23
+ Prawn::Labels.generate("custom_labels_1.pdf", fancy_names, :type => "Agipa119461") do |pdf, name|
24
+ pdf.text name
25
+ end
26
+
27
+ #use a configuration file for custom labels
28
+ Prawn::Labels.types = File.join(File.dirname(__FILE__), "custom_label.yml")
29
+
30
+ Prawn::Labels.generate("custom_labels_2.pdf", fancy_names, :type => "quartersheet") do |pdf, name|
31
+ pdf.text name
32
+ end
@@ -0,0 +1,11 @@
1
+ # quarter half sheet labels
2
+ quartersheet:
3
+ paper_size: A4
4
+ top_margin: 36.57
5
+ bottom_margin: 0
6
+ left_margin: 20.551
7
+ right_margin: 20.551
8
+ columns: 2
9
+ rows: 2
10
+ column_gutter: 7.087
11
+ row_gutter: 0
@@ -0,0 +1,329 @@
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 2
16
+ /Kids [5 0 R 8 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 1668
21
+ >>
22
+ stream
23
+ q
24
+
25
+ BT
26
+ 20.551 796.704 Td
27
+ /F1.0 12 Tf
28
+ [<4a6f7264616e>] TJ
29
+ ET
30
+
31
+
32
+ BT
33
+ 207.63933333333333 796.704 Td
34
+ /F1.0 12 Tf
35
+ [<436872> -15 <6973>] TJ
36
+ ET
37
+
38
+
39
+ BT
40
+ 394.72766666666666 796.704 Td
41
+ /F1.0 12 Tf
42
+ [<4a6f6e>] TJ
43
+ ET
44
+
45
+
46
+ BT
47
+ 20.551 696.039 Td
48
+ /F1.0 12 Tf
49
+ [<4d696b> 20 <65>] TJ
50
+ ET
51
+
52
+
53
+ BT
54
+ 207.63933333333333 696.039 Td
55
+ /F1.0 12 Tf
56
+ [<4b> 40 <656c6c79>] TJ
57
+ ET
58
+
59
+
60
+ BT
61
+ 394.72766666666666 696.039 Td
62
+ /F1.0 12 Tf
63
+ [<426f62>] TJ
64
+ ET
65
+
66
+
67
+ BT
68
+ 20.551 595.374 Td
69
+ /F1.0 12 Tf
70
+ [<47726567>] TJ
71
+ ET
72
+
73
+
74
+ BT
75
+ 207.63933333333333 595.374 Td
76
+ /F1.0 12 Tf
77
+ [<4a6f7264616e>] TJ
78
+ ET
79
+
80
+
81
+ BT
82
+ 394.72766666666666 595.374 Td
83
+ /F1.0 12 Tf
84
+ [<436872> -15 <6973>] TJ
85
+ ET
86
+
87
+
88
+ BT
89
+ 20.551 494.70899999999995 Td
90
+ /F1.0 12 Tf
91
+ [<4a6f6e>] TJ
92
+ ET
93
+
94
+
95
+ BT
96
+ 207.63933333333333 494.70899999999995 Td
97
+ /F1.0 12 Tf
98
+ [<4d696b> 20 <65>] TJ
99
+ ET
100
+
101
+
102
+ BT
103
+ 394.72766666666666 494.70899999999995 Td
104
+ /F1.0 12 Tf
105
+ [<4b> 40 <656c6c79>] TJ
106
+ ET
107
+
108
+
109
+ BT
110
+ 20.551 394.044 Td
111
+ /F1.0 12 Tf
112
+ [<426f62>] TJ
113
+ ET
114
+
115
+
116
+ BT
117
+ 207.63933333333333 394.044 Td
118
+ /F1.0 12 Tf
119
+ [<47726567>] TJ
120
+ ET
121
+
122
+
123
+ BT
124
+ 394.72766666666666 394.044 Td
125
+ /F1.0 12 Tf
126
+ [<4a6f7264616e>] TJ
127
+ ET
128
+
129
+
130
+ BT
131
+ 20.551 293.379 Td
132
+ /F1.0 12 Tf
133
+ [<436872> -15 <6973>] TJ
134
+ ET
135
+
136
+
137
+ BT
138
+ 207.63933333333333 293.379 Td
139
+ /F1.0 12 Tf
140
+ [<4a6f6e>] TJ
141
+ ET
142
+
143
+
144
+ BT
145
+ 394.72766666666666 293.379 Td
146
+ /F1.0 12 Tf
147
+ [<4d696b> 20 <65>] TJ
148
+ ET
149
+
150
+
151
+ BT
152
+ 20.551 192.71399999999994 Td
153
+ /F1.0 12 Tf
154
+ [<4b> 40 <656c6c79>] TJ
155
+ ET
156
+
157
+
158
+ BT
159
+ 207.63933333333333 192.71399999999994 Td
160
+ /F1.0 12 Tf
161
+ [<426f62>] TJ
162
+ ET
163
+
164
+
165
+ BT
166
+ 394.72766666666666 192.71399999999994 Td
167
+ /F1.0 12 Tf
168
+ [<47726567>] TJ
169
+ ET
170
+
171
+
172
+ BT
173
+ 20.551 92.04899999999996 Td
174
+ /F1.0 12 Tf
175
+ [<4a6f7264616e>] TJ
176
+ ET
177
+
178
+
179
+ BT
180
+ 207.63933333333333 92.04899999999996 Td
181
+ /F1.0 12 Tf
182
+ [<436872> -15 <6973>] TJ
183
+ ET
184
+
185
+
186
+ BT
187
+ 394.72766666666666 92.04899999999996 Td
188
+ /F1.0 12 Tf
189
+ [<4a6f6e>] TJ
190
+ ET
191
+
192
+ Q
193
+
194
+ endstream
195
+ endobj
196
+ 5 0 obj
197
+ << /Type /Page
198
+ /Parent 3 0 R
199
+ /MediaBox [0 0 595.28 841.89]
200
+ /Contents 4 0 R
201
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
202
+ /Font << /F1.0 6 0 R
203
+ >>
204
+ >>
205
+ >>
206
+ endobj
207
+ 6 0 obj
208
+ << /Type /Font
209
+ /Subtype /Type1
210
+ /BaseFont /Helvetica
211
+ /Encoding /WinAnsiEncoding
212
+ >>
213
+ endobj
214
+ 7 0 obj
215
+ << /Length 739
216
+ >>
217
+ stream
218
+ q
219
+
220
+ BT
221
+ 20.551 796.704 Td
222
+ /F1.0 12 Tf
223
+ [<4d696b> 20 <65>] TJ
224
+ ET
225
+
226
+
227
+ BT
228
+ 207.63933333333333 796.704 Td
229
+ /F1.0 12 Tf
230
+ [<4b> 40 <656c6c79>] TJ
231
+ ET
232
+
233
+
234
+ BT
235
+ 394.72766666666666 796.704 Td
236
+ /F1.0 12 Tf
237
+ [<426f62>] TJ
238
+ ET
239
+
240
+
241
+ BT
242
+ 20.551 696.039 Td
243
+ /F1.0 12 Tf
244
+ [<47726567>] TJ
245
+ ET
246
+
247
+
248
+ BT
249
+ 207.63933333333333 696.039 Td
250
+ /F1.0 12 Tf
251
+ [<4a6f7264616e>] TJ
252
+ ET
253
+
254
+
255
+ BT
256
+ 394.72766666666666 696.039 Td
257
+ /F1.0 12 Tf
258
+ [<436872> -15 <6973>] TJ
259
+ ET
260
+
261
+
262
+ BT
263
+ 20.551 595.374 Td
264
+ /F1.0 12 Tf
265
+ [<4a6f6e>] TJ
266
+ ET
267
+
268
+
269
+ BT
270
+ 207.63933333333333 595.374 Td
271
+ /F1.0 12 Tf
272
+ [<4d696b> 20 <65>] TJ
273
+ ET
274
+
275
+
276
+ BT
277
+ 394.72766666666666 595.374 Td
278
+ /F1.0 12 Tf
279
+ [<4b> 40 <656c6c79>] TJ
280
+ ET
281
+
282
+
283
+ BT
284
+ 20.551 494.70899999999995 Td
285
+ /F1.0 12 Tf
286
+ [<426f62>] TJ
287
+ ET
288
+
289
+
290
+ BT
291
+ 207.63933333333333 494.70899999999995 Td
292
+ /F1.0 12 Tf
293
+ [<47726567>] TJ
294
+ ET
295
+
296
+ Q
297
+
298
+ endstream
299
+ endobj
300
+ 8 0 obj
301
+ << /Type /Page
302
+ /Parent 3 0 R
303
+ /MediaBox [0 0 595.28 841.89]
304
+ /Contents 7 0 R
305
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
306
+ /Font << /F1.0 6 0 R
307
+ >>
308
+ >>
309
+ >>
310
+ endobj
311
+ xref
312
+ 0 9
313
+ 0000000000 65535 f
314
+ 0000000015 00000 n
315
+ 0000000109 00000 n
316
+ 0000000158 00000 n
317
+ 0000000221 00000 n
318
+ 0000001941 00000 n
319
+ 0000002121 00000 n
320
+ 0000002218 00000 n
321
+ 0000003008 00000 n
322
+ trailer
323
+ << /Size 9
324
+ /Root 2 0 R
325
+ /Info 1 0 R
326
+ >>
327
+ startxref
328
+ 3188
329
+ %%EOF
@@ -0,0 +1,483 @@
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 9
16
+ /Kids [5 0 R 8 0 R 10 0 R 12 0 R 14 0 R 16 0 R 18 0 R 20 0 R 22 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 241
21
+ >>
22
+ stream
23
+ q
24
+
25
+ BT
26
+ 20.551 796.704 Td
27
+ /F1.0 12 Tf
28
+ [<4a6f7264616e>] TJ
29
+ ET
30
+
31
+
32
+ BT
33
+ 301.1835 796.704 Td
34
+ /F1.0 12 Tf
35
+ [<436872> -15 <6973>] TJ
36
+ ET
37
+
38
+
39
+ BT
40
+ 20.551 394.044 Td
41
+ /F1.0 12 Tf
42
+ [<4a6f6e>] TJ
43
+ ET
44
+
45
+
46
+ BT
47
+ 301.1835 394.044 Td
48
+ /F1.0 12 Tf
49
+ [<4d696b> 20 <65>] TJ
50
+ ET
51
+
52
+ Q
53
+
54
+ endstream
55
+ endobj
56
+ 5 0 obj
57
+ << /Type /Page
58
+ /Parent 3 0 R
59
+ /MediaBox [0 0 595.28 841.89]
60
+ /Contents 4 0 R
61
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
62
+ /Font << /F1.0 6 0 R
63
+ >>
64
+ >>
65
+ >>
66
+ endobj
67
+ 6 0 obj
68
+ << /Type /Font
69
+ /Subtype /Type1
70
+ /BaseFont /Helvetica
71
+ /Encoding /WinAnsiEncoding
72
+ >>
73
+ endobj
74
+ 7 0 obj
75
+ << /Length 234
76
+ >>
77
+ stream
78
+ q
79
+
80
+ BT
81
+ 20.551 796.704 Td
82
+ /F1.0 12 Tf
83
+ [<4b> 40 <656c6c79>] TJ
84
+ ET
85
+
86
+
87
+ BT
88
+ 301.1835 796.704 Td
89
+ /F1.0 12 Tf
90
+ [<426f62>] TJ
91
+ ET
92
+
93
+
94
+ BT
95
+ 20.551 394.044 Td
96
+ /F1.0 12 Tf
97
+ [<47726567>] TJ
98
+ ET
99
+
100
+
101
+ BT
102
+ 301.1835 394.044 Td
103
+ /F1.0 12 Tf
104
+ [<4a6f7264616e>] TJ
105
+ ET
106
+
107
+ Q
108
+
109
+ endstream
110
+ endobj
111
+ 8 0 obj
112
+ << /Type /Page
113
+ /Parent 3 0 R
114
+ /MediaBox [0 0 595.28 841.89]
115
+ /Contents 7 0 R
116
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
117
+ /Font << /F1.0 6 0 R
118
+ >>
119
+ >>
120
+ >>
121
+ endobj
122
+ 9 0 obj
123
+ << /Length 245
124
+ >>
125
+ stream
126
+ q
127
+
128
+ BT
129
+ 20.551 796.704 Td
130
+ /F1.0 12 Tf
131
+ [<436872> -15 <6973>] TJ
132
+ ET
133
+
134
+
135
+ BT
136
+ 301.1835 796.704 Td
137
+ /F1.0 12 Tf
138
+ [<4a6f6e>] TJ
139
+ ET
140
+
141
+
142
+ BT
143
+ 20.551 394.044 Td
144
+ /F1.0 12 Tf
145
+ [<4d696b> 20 <65>] TJ
146
+ ET
147
+
148
+
149
+ BT
150
+ 301.1835 394.044 Td
151
+ /F1.0 12 Tf
152
+ [<4b> 40 <656c6c79>] TJ
153
+ ET
154
+
155
+ Q
156
+
157
+ endstream
158
+ endobj
159
+ 10 0 obj
160
+ << /Type /Page
161
+ /Parent 3 0 R
162
+ /MediaBox [0 0 595.28 841.89]
163
+ /Contents 9 0 R
164
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
165
+ /Font << /F1.0 6 0 R
166
+ >>
167
+ >>
168
+ >>
169
+ endobj
170
+ 11 0 obj
171
+ << /Length 235
172
+ >>
173
+ stream
174
+ q
175
+
176
+ BT
177
+ 20.551 796.704 Td
178
+ /F1.0 12 Tf
179
+ [<426f62>] TJ
180
+ ET
181
+
182
+
183
+ BT
184
+ 301.1835 796.704 Td
185
+ /F1.0 12 Tf
186
+ [<47726567>] TJ
187
+ ET
188
+
189
+
190
+ BT
191
+ 20.551 394.044 Td
192
+ /F1.0 12 Tf
193
+ [<4a6f7264616e>] TJ
194
+ ET
195
+
196
+
197
+ BT
198
+ 301.1835 394.044 Td
199
+ /F1.0 12 Tf
200
+ [<436872> -15 <6973>] TJ
201
+ ET
202
+
203
+ Q
204
+
205
+ endstream
206
+ endobj
207
+ 12 0 obj
208
+ << /Type /Page
209
+ /Parent 3 0 R
210
+ /MediaBox [0 0 595.28 841.89]
211
+ /Contents 11 0 R
212
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
213
+ /Font << /F1.0 6 0 R
214
+ >>
215
+ >>
216
+ >>
217
+ endobj
218
+ 13 0 obj
219
+ << /Length 234
220
+ >>
221
+ stream
222
+ q
223
+
224
+ BT
225
+ 20.551 796.704 Td
226
+ /F1.0 12 Tf
227
+ [<4a6f6e>] TJ
228
+ ET
229
+
230
+
231
+ BT
232
+ 301.1835 796.704 Td
233
+ /F1.0 12 Tf
234
+ [<4d696b> 20 <65>] TJ
235
+ ET
236
+
237
+
238
+ BT
239
+ 20.551 394.044 Td
240
+ /F1.0 12 Tf
241
+ [<4b> 40 <656c6c79>] TJ
242
+ ET
243
+
244
+
245
+ BT
246
+ 301.1835 394.044 Td
247
+ /F1.0 12 Tf
248
+ [<426f62>] TJ
249
+ ET
250
+
251
+ Q
252
+
253
+ endstream
254
+ endobj
255
+ 14 0 obj
256
+ << /Type /Page
257
+ /Parent 3 0 R
258
+ /MediaBox [0 0 595.28 841.89]
259
+ /Contents 13 0 R
260
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
261
+ /Font << /F1.0 6 0 R
262
+ >>
263
+ >>
264
+ >>
265
+ endobj
266
+ 15 0 obj
267
+ << /Length 235
268
+ >>
269
+ stream
270
+ q
271
+
272
+ BT
273
+ 20.551 796.704 Td
274
+ /F1.0 12 Tf
275
+ [<47726567>] TJ
276
+ ET
277
+
278
+
279
+ BT
280
+ 301.1835 796.704 Td
281
+ /F1.0 12 Tf
282
+ [<4a6f7264616e>] TJ
283
+ ET
284
+
285
+
286
+ BT
287
+ 20.551 394.044 Td
288
+ /F1.0 12 Tf
289
+ [<436872> -15 <6973>] TJ
290
+ ET
291
+
292
+
293
+ BT
294
+ 301.1835 394.044 Td
295
+ /F1.0 12 Tf
296
+ [<4a6f6e>] TJ
297
+ ET
298
+
299
+ Q
300
+
301
+ endstream
302
+ endobj
303
+ 16 0 obj
304
+ << /Type /Page
305
+ /Parent 3 0 R
306
+ /MediaBox [0 0 595.28 841.89]
307
+ /Contents 15 0 R
308
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
309
+ /Font << /F1.0 6 0 R
310
+ >>
311
+ >>
312
+ >>
313
+ endobj
314
+ 17 0 obj
315
+ << /Length 236
316
+ >>
317
+ stream
318
+ q
319
+
320
+ BT
321
+ 20.551 796.704 Td
322
+ /F1.0 12 Tf
323
+ [<4d696b> 20 <65>] TJ
324
+ ET
325
+
326
+
327
+ BT
328
+ 301.1835 796.704 Td
329
+ /F1.0 12 Tf
330
+ [<4b> 40 <656c6c79>] TJ
331
+ ET
332
+
333
+
334
+ BT
335
+ 20.551 394.044 Td
336
+ /F1.0 12 Tf
337
+ [<426f62>] TJ
338
+ ET
339
+
340
+
341
+ BT
342
+ 301.1835 394.044 Td
343
+ /F1.0 12 Tf
344
+ [<47726567>] TJ
345
+ ET
346
+
347
+ Q
348
+
349
+ endstream
350
+ endobj
351
+ 18 0 obj
352
+ << /Type /Page
353
+ /Parent 3 0 R
354
+ /MediaBox [0 0 595.28 841.89]
355
+ /Contents 17 0 R
356
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
357
+ /Font << /F1.0 6 0 R
358
+ >>
359
+ >>
360
+ >>
361
+ endobj
362
+ 19 0 obj
363
+ << /Length 241
364
+ >>
365
+ stream
366
+ q
367
+
368
+ BT
369
+ 20.551 796.704 Td
370
+ /F1.0 12 Tf
371
+ [<4a6f7264616e>] TJ
372
+ ET
373
+
374
+
375
+ BT
376
+ 301.1835 796.704 Td
377
+ /F1.0 12 Tf
378
+ [<436872> -15 <6973>] TJ
379
+ ET
380
+
381
+
382
+ BT
383
+ 20.551 394.044 Td
384
+ /F1.0 12 Tf
385
+ [<4a6f6e>] TJ
386
+ ET
387
+
388
+
389
+ BT
390
+ 301.1835 394.044 Td
391
+ /F1.0 12 Tf
392
+ [<4d696b> 20 <65>] TJ
393
+ ET
394
+
395
+ Q
396
+
397
+ endstream
398
+ endobj
399
+ 20 0 obj
400
+ << /Type /Page
401
+ /Parent 3 0 R
402
+ /MediaBox [0 0 595.28 841.89]
403
+ /Contents 19 0 R
404
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
405
+ /Font << /F1.0 6 0 R
406
+ >>
407
+ >>
408
+ >>
409
+ endobj
410
+ 21 0 obj
411
+ << /Length 174
412
+ >>
413
+ stream
414
+ q
415
+
416
+ BT
417
+ 20.551 796.704 Td
418
+ /F1.0 12 Tf
419
+ [<4b> 40 <656c6c79>] TJ
420
+ ET
421
+
422
+
423
+ BT
424
+ 301.1835 796.704 Td
425
+ /F1.0 12 Tf
426
+ [<426f62>] TJ
427
+ ET
428
+
429
+
430
+ BT
431
+ 20.551 394.044 Td
432
+ /F1.0 12 Tf
433
+ [<47726567>] TJ
434
+ ET
435
+
436
+ Q
437
+
438
+ endstream
439
+ endobj
440
+ 22 0 obj
441
+ << /Type /Page
442
+ /Parent 3 0 R
443
+ /MediaBox [0 0 595.28 841.89]
444
+ /Contents 21 0 R
445
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
446
+ /Font << /F1.0 6 0 R
447
+ >>
448
+ >>
449
+ >>
450
+ endobj
451
+ xref
452
+ 0 23
453
+ 0000000000 65535 f
454
+ 0000000015 00000 n
455
+ 0000000109 00000 n
456
+ 0000000158 00000 n
457
+ 0000000270 00000 n
458
+ 0000000562 00000 n
459
+ 0000000742 00000 n
460
+ 0000000839 00000 n
461
+ 0000001124 00000 n
462
+ 0000001304 00000 n
463
+ 0000001600 00000 n
464
+ 0000001781 00000 n
465
+ 0000002068 00000 n
466
+ 0000002250 00000 n
467
+ 0000002536 00000 n
468
+ 0000002718 00000 n
469
+ 0000003005 00000 n
470
+ 0000003187 00000 n
471
+ 0000003475 00000 n
472
+ 0000003657 00000 n
473
+ 0000003950 00000 n
474
+ 0000004132 00000 n
475
+ 0000004358 00000 n
476
+ trailer
477
+ << /Size 23
478
+ /Root 2 0 R
479
+ /Info 1 0 R
480
+ >>
481
+ startxref
482
+ 4540
483
+ %%EOF
Binary file
data/lib/prawn/labels.rb CHANGED
@@ -11,21 +11,37 @@ module Prawn
11
11
  class Labels
12
12
  attr_reader :document, :type
13
13
 
14
- def self.generate(file_name, data, options = {}, &block)
15
- labels = Labels.new(data, options, &block)
16
- labels.document.render_file(file_name)
17
- end
14
+ class << self
15
+
16
+ def generate(file_name, data, options = {}, &block)
17
+ labels = Labels.new(data, options, &block)
18
+ labels.document.render_file(file_name)
19
+ end
20
+
21
+ def render(data, options = {}, &block)
22
+ labels = Labels.new(data, options, &block)
23
+ labels.document.render
24
+ end
25
+
26
+ def types=(custom_types)
27
+ if custom_types.is_a? Hash
28
+ types.merge! custom_types
29
+ elsif custom_types.is_a?(String) && File.exist?(custom_types)
30
+ types.merge! YAML.load_file(custom_types)
31
+ end
32
+ end
33
+
34
+ def types
35
+ @types ||= begin
36
+ types_file = File.join(File.dirname(__FILE__), 'types.yaml')
37
+ YAML.load_file(types_file)
38
+ end
39
+ end
18
40
 
19
- def self.render(data, options = {}, &block)
20
- labels = Labels.new(data, options, &block)
21
- labels.document.render
22
41
  end
23
42
 
24
43
  def initialize(data, options = {}, &block)
25
- types_file = File.join(File.dirname(__FILE__), 'types.yaml')
26
- types = YAML.load_file(types_file)
27
-
28
- unless @type = types[options[:type]]
44
+ unless @type = Labels.types[options[:type]]
29
45
  raise "Label Type Unknown '#{options[:type]}'"
30
46
  end
31
47
 
data/prawn-labels.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- PRAWN_LABELS_VERSION = "0.11.2.2"
1
+ PRAWN_LABELS_VERSION = "0.11.3.0"
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prawn-labels"
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 11
8
- - 2
9
- - 2
10
- version: 0.11.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.11.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Byron
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-01 00:00:00 -05:00
18
+ date: 2012-05-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -45,6 +45,10 @@ extra_rdoc_files:
45
45
  - LICENSE
46
46
  - COPYING
47
47
  files:
48
+ - examples/custom_label.rb
49
+ - examples/custom_label.yml
50
+ - examples/custom_labels_1.pdf
51
+ - examples/custom_labels_2.pdf
48
52
  - examples/envelope_labels.pdf
49
53
  - examples/envelope_labels.rb
50
54
  - examples/example_helper.rb