pdf-wrapper 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -0
- data/Rakefile +4 -4
- data/examples/cell.rb +1 -1
- data/examples/image.rb +3 -3
- data/examples/markup.rb +12 -0
- data/examples/repeating.rb +1 -1
- data/examples/scaled.rb +38 -0
- data/examples/scaled_cells.rb +30 -0
- data/examples/scaled_image.rb +14 -0
- data/examples/shapes.rb +1 -1
- data/examples/table.rb +25 -4
- data/examples/translate.rb +21 -0
- data/examples/utf8-long.rb +1 -2
- data/examples/utf8.rb +1 -2
- data/lib/pdf/core.rb +23 -0
- data/lib/pdf/wrapper.rb +136 -760
- data/lib/pdf/wrapper/graphics.rb +116 -0
- data/lib/pdf/wrapper/images.rb +206 -0
- data/lib/pdf/wrapper/loading.rb +52 -0
- data/lib/pdf/wrapper/table.rb +473 -0
- data/lib/pdf/wrapper/text.rb +337 -0
- data/specs/data/windmill.jpg +0 -0
- data/specs/{shapes_spec.rb → graphics_spec.rb} +3 -3
- data/specs/spec_helper.rb +6 -1
- data/specs/tables_spec.rb +111 -0
- data/specs/text_spec.rb +63 -2
- data/specs/wrapper_spec.rb +145 -72
- metadata +20 -9
- data/examples/padded_image.rb +0 -12
- data/examples/template.rb +0 -13
data/specs/text_spec.rb
CHANGED
@@ -16,7 +16,7 @@ context "The PDF::Wrapper class" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
specify "should be able to add unicode text to the canvas" do
|
19
|
-
msg = "
|
19
|
+
msg = "Alex Čihař"
|
20
20
|
pdf = PDF::Wrapper.new
|
21
21
|
pdf.text msg
|
22
22
|
|
@@ -96,8 +96,14 @@ context "The PDF::Wrapper class" do
|
|
96
96
|
(params[4] < pdf.absolute_right_margin).should be_true
|
97
97
|
end
|
98
98
|
|
99
|
+
specify "should raise an error when an invalid alignment is specified" do
|
100
|
+
msg = "James Healy"
|
101
|
+
pdf = PDF::Wrapper.new
|
102
|
+
lambda { pdf.text msg, :alignment => :ponies }.should raise_error(ArgumentError)
|
103
|
+
end
|
104
|
+
|
99
105
|
specify "should be able to add text to the canvas in a bounding box using the cell method" do
|
100
|
-
msg = "
|
106
|
+
msg = "Alex Čihař"
|
101
107
|
pdf = PDF::Wrapper.new
|
102
108
|
pdf.cell msg, 100, 100, 200, 200
|
103
109
|
|
@@ -174,4 +180,59 @@ context "The PDF::Wrapper class" do
|
|
174
180
|
|
175
181
|
specify "should raise an error when a string that isn't convertable to UTF-8 is passed into build_pango_layout()"
|
176
182
|
end
|
183
|
+
|
184
|
+
specify "should accept and render pango markup correctly" do
|
185
|
+
msg = "<b>James</b>"
|
186
|
+
pdf = PDF::Wrapper.new
|
187
|
+
pdf.text msg, :markup => :pango
|
188
|
+
|
189
|
+
receiver = PageTextReceiver.new
|
190
|
+
reader = PDF::Reader.string(pdf.render, receiver)
|
191
|
+
|
192
|
+
page_one = receiver.content.first.dup
|
193
|
+
page_one.should eql("James")
|
194
|
+
end
|
195
|
+
|
196
|
+
specify "should be able to alle to wrap text on word boundaries" do
|
197
|
+
msg = "James Healy"
|
198
|
+
pdf = PDF::Wrapper.new
|
199
|
+
pdf.text msg, :wrap => :word
|
200
|
+
|
201
|
+
receiver = PageTextReceiver.new
|
202
|
+
reader = PDF::Reader.string(pdf.render, receiver)
|
203
|
+
|
204
|
+
# TODO: test for the text is in the appropriate location on the page
|
205
|
+
receiver.content.first.should eql(msg)
|
206
|
+
end
|
207
|
+
|
208
|
+
specify "should be able to able to wrap text on char boundaries" do
|
209
|
+
msg = "James Healy"
|
210
|
+
pdf = PDF::Wrapper.new
|
211
|
+
pdf.text msg, :wrap => :char
|
212
|
+
|
213
|
+
receiver = PageTextReceiver.new
|
214
|
+
reader = PDF::Reader.string(pdf.render, receiver)
|
215
|
+
|
216
|
+
# TODO: test for the text is in the appropriate location on the page
|
217
|
+
receiver.content.first.should eql(msg)
|
218
|
+
end
|
219
|
+
|
220
|
+
specify "should be able to wrap text on word and char boundaries" do
|
221
|
+
msg = "James Healy"
|
222
|
+
pdf = PDF::Wrapper.new
|
223
|
+
pdf.text msg, :wrap => :wordchar
|
224
|
+
|
225
|
+
receiver = PageTextReceiver.new
|
226
|
+
reader = PDF::Reader.string(pdf.render, receiver)
|
227
|
+
|
228
|
+
# TODO: test for the text is in the appropriate location on the page
|
229
|
+
receiver.content.first.should eql(msg)
|
230
|
+
end
|
231
|
+
|
232
|
+
specify "should raise an error when an invalid wrapping technique is specified" do
|
233
|
+
msg = "James Healy"
|
234
|
+
pdf = PDF::Wrapper.new
|
235
|
+
lambda { pdf.text msg, :wrap => :ponies }.should raise_error(ArgumentError)
|
236
|
+
end
|
237
|
+
|
177
238
|
end
|
data/specs/wrapper_spec.rb
CHANGED
@@ -41,36 +41,22 @@ context "The PDF::Wrapper class" do
|
|
41
41
|
|
42
42
|
specify "should initilize with the correct default text and colour settings" do
|
43
43
|
pdf = PDF::Wrapper.new
|
44
|
-
pdf.instance_variable_get("@default_color").should eql([0.0,0.0,0.0,1.0])
|
45
44
|
pdf.instance_variable_get("@default_font").should eql("Sans Serif")
|
46
45
|
pdf.instance_variable_get("@default_font_size").should eql(16)
|
47
|
-
pdf.instance_variable_get("@default_line_width").should eql(2.0)
|
48
|
-
end
|
49
|
-
|
50
|
-
specify "should be able to change the default color" do
|
51
|
-
pdf = PDF::Wrapper.new
|
52
|
-
pdf.default_color(:red)
|
53
|
-
pdf.instance_variable_get("@default_color").should eql([1.0,0.0,0.0,1.0])
|
54
46
|
end
|
55
47
|
|
56
48
|
specify "should be able to change the default font" do
|
57
49
|
pdf = PDF::Wrapper.new
|
58
|
-
pdf.
|
50
|
+
pdf.font("Arial")
|
59
51
|
pdf.instance_variable_get("@default_font").should eql("Arial")
|
60
52
|
end
|
61
53
|
|
62
54
|
specify "should be able to change the default font size" do
|
63
55
|
pdf = PDF::Wrapper.new
|
64
|
-
pdf.
|
56
|
+
pdf.font_size(24)
|
65
57
|
pdf.instance_variable_get("@default_font_size").should eql(24)
|
66
58
|
end
|
67
59
|
|
68
|
-
specify "should be able to change the default line width" do
|
69
|
-
pdf = PDF::Wrapper.new
|
70
|
-
pdf.default_line_width(10)
|
71
|
-
pdf.instance_variable_get("@default_line_width").should eql(10)
|
72
|
-
end
|
73
|
-
|
74
60
|
specify "should initialize with the cursor at the top left of the body of the page" do
|
75
61
|
pdf = PDF::Wrapper.new
|
76
62
|
x,y = pdf.current_point
|
@@ -92,8 +78,8 @@ context "The PDF::Wrapper class" do
|
|
92
78
|
pdf.absolute_y_middle.should eql(PDF::Wrapper::PAGE_SIZES[:A4].last / 2)
|
93
79
|
pdf.body_width.should eql(pdf.page_width - pdf.margin_left - pdf.margin_right)
|
94
80
|
pdf.body_height.should eql(pdf.page_height - pdf.margin_top - pdf.margin_bottom)
|
95
|
-
pdf.
|
96
|
-
pdf.
|
81
|
+
pdf.body_x_middle.should eql(pdf.margin_left + (pdf.body_width/ 2))
|
82
|
+
pdf.body_y_middle.should eql(pdf.margin_top + (pdf.body_height/ 2))
|
97
83
|
pdf.points_to_bottom_margin(300).should eql(pdf.absolute_bottom_margin - 300)
|
98
84
|
pdf.points_to_right_margin(300).should eql(pdf.absolute_right_margin - 300)
|
99
85
|
end
|
@@ -106,10 +92,14 @@ context "The PDF::Wrapper class" do
|
|
106
92
|
y.to_i.should eql(100)
|
107
93
|
end
|
108
94
|
|
109
|
-
specify "should
|
95
|
+
specify "should be able to move the cursor to any arbitary point on the canvas when scaled" do
|
110
96
|
pdf = PDF::Wrapper.new
|
111
|
-
|
112
|
-
|
97
|
+
pdf.scale(pdf.page_width, pdf.page_height) do
|
98
|
+
pdf.move_to(0.5, 0.5)
|
99
|
+
x,y = pdf.current_point
|
100
|
+
sprintf("%0.1f",x).should eql("0.5")
|
101
|
+
sprintf("%0.1f",y).should eql("0.5")
|
102
|
+
end
|
113
103
|
end
|
114
104
|
|
115
105
|
specify "should be able to shift the y position of the cursor using pad" do
|
@@ -171,24 +161,6 @@ context "The PDF::Wrapper class" do
|
|
171
161
|
tmp.unlink
|
172
162
|
end
|
173
163
|
|
174
|
-
specify "should be able to draw a table on the canvas"
|
175
|
-
|
176
|
-
specify "should leave the cursor in the bottom left when adding a table" do
|
177
|
-
pdf = PDF::Wrapper.new
|
178
|
-
data = [%w{head1 head2},%w{data1 data2}]
|
179
|
-
pdf.table(data, :left => pdf.margin_left)
|
180
|
-
x,y = pdf.current_point
|
181
|
-
x.to_i.should eql(pdf.margin_left)
|
182
|
-
end
|
183
|
-
|
184
|
-
specify "should default to using as much available space when adding a table that isn't left aligned with the left margin" do
|
185
|
-
pdf = PDF::Wrapper.new
|
186
|
-
data = [%w{head1 head2},%w{data1 data2}]
|
187
|
-
pdf.table(data, :left => 100)
|
188
|
-
x,y = pdf.current_point
|
189
|
-
x.to_i.should eql(100)
|
190
|
-
end
|
191
|
-
|
192
164
|
specify "should be able to determine if a requested colour is valid or not" do
|
193
165
|
pdf = PDF::Wrapper.new
|
194
166
|
pdf.validate_color(:black).should be_true
|
@@ -203,15 +175,15 @@ context "The PDF::Wrapper class" do
|
|
203
175
|
test_str = "repeating"
|
204
176
|
|
205
177
|
pdf = PDF::Wrapper.new
|
206
|
-
pdf.repeating_element(:all) { pdf.text test_str }
|
207
|
-
|
178
|
+
pdf.repeating_element(:all) { pdf.text test_str }
|
179
|
+
|
208
180
|
pdf.start_new_page
|
209
181
|
pdf.start_new_page
|
210
182
|
pdf.start_new_page
|
211
|
-
|
183
|
+
|
212
184
|
receiver = PageTextReceiver.new
|
213
185
|
reader = PDF::Reader.string(pdf.render, receiver)
|
214
|
-
|
186
|
+
|
215
187
|
receiver.content.size.should eql(4)
|
216
188
|
receiver.content[0].should eql(test_str)
|
217
189
|
receiver.content[1].should eql(test_str)
|
@@ -223,15 +195,15 @@ context "The PDF::Wrapper class" do
|
|
223
195
|
test_str = "repeating"
|
224
196
|
|
225
197
|
pdf = PDF::Wrapper.new
|
226
|
-
pdf.repeating_element(:odd) { pdf.text test_str }
|
227
|
-
|
198
|
+
pdf.repeating_element(:odd) { pdf.text test_str }
|
199
|
+
|
228
200
|
pdf.start_new_page
|
229
201
|
pdf.start_new_page
|
230
202
|
pdf.start_new_page
|
231
|
-
|
203
|
+
|
232
204
|
receiver = PageTextReceiver.new
|
233
205
|
reader = PDF::Reader.string(pdf.render, receiver)
|
234
|
-
|
206
|
+
|
235
207
|
receiver.content.size.should eql(4)
|
236
208
|
receiver.content[0].should eql(test_str)
|
237
209
|
receiver.content[1].should eql("")
|
@@ -243,15 +215,15 @@ context "The PDF::Wrapper class" do
|
|
243
215
|
test_str = "repeating"
|
244
216
|
|
245
217
|
pdf = PDF::Wrapper.new
|
246
|
-
pdf.repeating_element(:even) { pdf.text test_str }
|
247
|
-
|
218
|
+
pdf.repeating_element(:even) { pdf.text test_str }
|
219
|
+
|
248
220
|
pdf.start_new_page
|
249
221
|
pdf.start_new_page
|
250
222
|
pdf.start_new_page
|
251
|
-
|
223
|
+
|
252
224
|
receiver = PageTextReceiver.new
|
253
225
|
reader = PDF::Reader.string(pdf.render, receiver)
|
254
|
-
|
226
|
+
|
255
227
|
receiver.content.size.should eql(4)
|
256
228
|
receiver.content[0].should eql("")
|
257
229
|
receiver.content[1].should eql(test_str)
|
@@ -263,15 +235,15 @@ context "The PDF::Wrapper class" do
|
|
263
235
|
test_str = "repeating"
|
264
236
|
|
265
237
|
pdf = PDF::Wrapper.new
|
266
|
-
pdf.repeating_element((2..3)) { pdf.text test_str }
|
267
|
-
|
238
|
+
pdf.repeating_element((2..3)) { pdf.text test_str }
|
239
|
+
|
268
240
|
pdf.start_new_page
|
269
241
|
pdf.start_new_page
|
270
242
|
pdf.start_new_page
|
271
|
-
|
243
|
+
|
272
244
|
receiver = PageTextReceiver.new
|
273
245
|
reader = PDF::Reader.string(pdf.render, receiver)
|
274
|
-
|
246
|
+
|
275
247
|
receiver.content.size.should eql(4)
|
276
248
|
receiver.content[0].should eql("")
|
277
249
|
receiver.content[1].should eql(test_str)
|
@@ -283,15 +255,15 @@ context "The PDF::Wrapper class" do
|
|
283
255
|
test_str = "repeating"
|
284
256
|
|
285
257
|
pdf = PDF::Wrapper.new
|
286
|
-
pdf.repeating_element(2) { pdf.text test_str }
|
287
|
-
|
258
|
+
pdf.repeating_element(2) { pdf.text test_str }
|
259
|
+
|
288
260
|
pdf.start_new_page
|
289
261
|
pdf.start_new_page
|
290
262
|
pdf.start_new_page
|
291
|
-
|
263
|
+
|
292
264
|
receiver = PageTextReceiver.new
|
293
265
|
reader = PDF::Reader.string(pdf.render, receiver)
|
294
|
-
|
266
|
+
|
295
267
|
receiver.content.size.should eql(4)
|
296
268
|
receiver.content[0].should eql("")
|
297
269
|
receiver.content[1].should eql(test_str)
|
@@ -303,15 +275,15 @@ context "The PDF::Wrapper class" do
|
|
303
275
|
test_str = "repeating"
|
304
276
|
|
305
277
|
pdf = PDF::Wrapper.new
|
306
|
-
pdf.repeating_element([1,3,4]) { pdf.text test_str }
|
307
|
-
|
278
|
+
pdf.repeating_element([1,3,4]) { pdf.text test_str }
|
279
|
+
|
308
280
|
pdf.start_new_page
|
309
281
|
pdf.start_new_page
|
310
282
|
pdf.start_new_page
|
311
|
-
|
283
|
+
|
312
284
|
receiver = PageTextReceiver.new
|
313
285
|
reader = PDF::Reader.string(pdf.render, receiver)
|
314
|
-
|
286
|
+
|
315
287
|
receiver.content.size.should eql(4)
|
316
288
|
receiver.content[0].should eql(test_str)
|
317
289
|
receiver.content[1].should eql("")
|
@@ -386,12 +358,6 @@ context "The PDF::Wrapper class" do
|
|
386
358
|
x, y = pdf.current_point
|
387
359
|
x.should eql(origx)
|
388
360
|
y.should eql(origy)
|
389
|
-
|
390
|
-
# rounded_rectangle()
|
391
|
-
pdf.rounded_rectangle(200, 400, 100, 100, 10)
|
392
|
-
x, y = pdf.current_point
|
393
|
-
x.should eql(origx)
|
394
|
-
y.should eql(origy)
|
395
361
|
end
|
396
362
|
|
397
363
|
specify "should maintain an internal counter of pages" do
|
@@ -415,14 +381,13 @@ context "The PDF::Wrapper class" do
|
|
415
381
|
lambda { pdf.line(100,100,200,200, :ponies => true)}.should raise_error(ArgumentError)
|
416
382
|
lambda { pdf.rectangle(100,100,100,100, :ponies => true)}.should raise_error(ArgumentError)
|
417
383
|
lambda { pdf.start_new_page(:ponies => true)}.should raise_error(ArgumentError)
|
418
|
-
lambda { pdf.rounded_rectangle(100,100,100,100,10, :ponies => true)}.should raise_error(ArgumentError)
|
419
384
|
lambda { pdf.image(File.dirname(__FILE__) + "/data/orc.svg", :ponies => true)}.should raise_error(ArgumentError)
|
420
385
|
end
|
421
386
|
|
422
387
|
specify "should allow an existing file to be used as a template for page 1" do
|
423
388
|
pdf = PDF::Wrapper.new(:paper => :A4, :template => File.dirname(__FILE__) + "/data/orc.svg")
|
424
389
|
pdf.start_new_page
|
425
|
-
|
390
|
+
|
426
391
|
receiver = PageSizeReceiver.new
|
427
392
|
reader = PDF::Reader.string(pdf.render, receiver)
|
428
393
|
|
@@ -433,11 +398,119 @@ context "The PDF::Wrapper class" do
|
|
433
398
|
specify "should allow an existing file to be used as a template for page 2" do
|
434
399
|
pdf = PDF::Wrapper.new(:paper => :A4)
|
435
400
|
pdf.start_new_page(:template => File.dirname(__FILE__) + "/data/orc.svg")
|
436
|
-
|
401
|
+
|
437
402
|
receiver = PageSizeReceiver.new
|
438
403
|
reader = PDF::Reader.string(pdf.render, receiver)
|
439
404
|
|
440
405
|
receiver.pages[0].should eql([0.0, 0.0, 595.28, 841.89])
|
441
406
|
receiver.pages[1].should eql([0.0, 0.0, 734.0, 772.0])
|
442
407
|
end
|
408
|
+
|
409
|
+
specify "should return correct page dimensions when scaled" do
|
410
|
+
pdf = PDF::Wrapper.new(:paper => :A4)
|
411
|
+
|
412
|
+
pdf.scale(595.28, 841.89) do
|
413
|
+
pdf.page_width.should eql(1.0)
|
414
|
+
pdf.page_height.should eql(1.0)
|
415
|
+
pdf.absolute_x_middle.should eql(0.5)
|
416
|
+
pdf.absolute_y_middle.should eql(0.5)
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
specify "should return correct body dimensions when scaled" do
|
421
|
+
pdf = PDF::Wrapper.new(:paper => :A4, :margin_top => 10, :margin_right => 10, :margin_bottom => 10, :margin_left => 10)
|
422
|
+
|
423
|
+
# scale so the dimensions of the body are 1,1
|
424
|
+
pdf.scale(595.28 - 20, 841.89 - 20) do
|
425
|
+
pdf.body_width.should eql(1.0)
|
426
|
+
pdf.body_height.should eql(1.0)
|
427
|
+
pdf.body_x_middle.should eql(0.5)
|
428
|
+
pdf.body_y_middle.should eql(0.5)
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
specify "should correctly convert a user x co-ordinate to device" do
|
433
|
+
pdf = PDF::Wrapper.new(:paper => :A4, :margin_left => 40)
|
434
|
+
|
435
|
+
pdf.user_x_to_device_x(10).should eql(10.0)
|
436
|
+
|
437
|
+
# translate so that 0,0 is at the page body corner
|
438
|
+
pdf.translate(pdf.margin_left, pdf.margin_top) do
|
439
|
+
# a user x co-ord of 10 is now equal to a device co-ord of 50
|
440
|
+
pdf.user_x_to_device_x(10).should eql(50.0)
|
441
|
+
end
|
442
|
+
|
443
|
+
# scale so the dimensions of the page are 1,1
|
444
|
+
pdf.scale(pdf.page_width, pdf.page_height) do
|
445
|
+
pdf.user_x_to_device_x(0.5).should eql(595.28/2)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
specify "should correctly convert a user y co-ordinate to device" do
|
450
|
+
pdf = PDF::Wrapper.new(:paper => :A4, :margin_top => 40)
|
451
|
+
|
452
|
+
pdf.user_y_to_device_y(10).should eql(10.0)
|
453
|
+
|
454
|
+
# translate so that 0,0 is at the page body corner
|
455
|
+
pdf.translate(pdf.margin_left, pdf.margin_top) do
|
456
|
+
# a user y co-ord of 10 is now equal to a device co-ord of 50
|
457
|
+
pdf.user_y_to_device_y(10).should eql(50.0)
|
458
|
+
end
|
459
|
+
|
460
|
+
# scale so the dimensions of the page are 1,1
|
461
|
+
pdf.scale(pdf.page_width, pdf.page_height) do
|
462
|
+
pdf.user_y_to_device_y(0.5).should eql(841.89/2)
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
specify "should correctly convert a device x co-ordinate to user" do
|
467
|
+
pdf = PDF::Wrapper.new(:paper => :A4, :margin_left => 40)
|
468
|
+
|
469
|
+
pdf.device_x_to_user_x(10).should eql(10.0)
|
470
|
+
|
471
|
+
# translate so that 0,0 is at the page body corner
|
472
|
+
pdf.translate(pdf.margin_left, pdf.margin_top) do
|
473
|
+
pdf.device_x_to_user_x(50).should eql(10.0)
|
474
|
+
end
|
475
|
+
|
476
|
+
# scale so the dimensions of the page are 1,1
|
477
|
+
pdf.scale(pdf.page_width, pdf.page_height) do
|
478
|
+
pdf.device_x_to_user_x(595.28/2).should eql(0.5)
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
specify "should correctly convert a device y co-ordinate to user" do
|
483
|
+
pdf = PDF::Wrapper.new(:paper => :A4, :margin_top => 40)
|
484
|
+
|
485
|
+
pdf.device_y_to_user_y(10).should eql(10.0)
|
486
|
+
|
487
|
+
# translate so that 0,0 is at the page body corner
|
488
|
+
pdf.translate(pdf.margin_left, pdf.margin_top) do
|
489
|
+
pdf.device_y_to_user_y(50).should eql(10.0)
|
490
|
+
end
|
491
|
+
|
492
|
+
# scale so the dimensions of the page are 1,1
|
493
|
+
pdf.scale(pdf.page_width, pdf.page_height) do
|
494
|
+
pdf.device_y_to_user_y(841.89/2).should eql(0.5)
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
498
|
+
specify "should correctly convert a user distance to distance" do
|
499
|
+
pdf = PDF::Wrapper.new(:paper => :A4, :margin_top => 40)
|
500
|
+
|
501
|
+
pdf.user_to_device_dist(10,0).should eql([10.0,0.0])
|
502
|
+
pdf.user_to_device_dist(0,10).should eql([0.0,10.0])
|
503
|
+
|
504
|
+
# translate so that 0,0 is at the page body corner
|
505
|
+
pdf.translate(pdf.margin_left, pdf.margin_top) do
|
506
|
+
pdf.user_to_device_dist(10,0).should eql([10.0,0.0])
|
507
|
+
pdf.user_to_device_dist(0,10).should eql([0.0,10.0])
|
508
|
+
end
|
509
|
+
|
510
|
+
# scale so the dimensions of the page are 1,1
|
511
|
+
pdf.scale(pdf.page_width, pdf.page_height) do
|
512
|
+
pdf.user_to_device_dist(0.5,0).should eql([595.28/2,0.0])
|
513
|
+
pdf.user_to_device_dist(0,0.5).should eql([0.0,841.89/2])
|
514
|
+
end
|
515
|
+
end
|
443
516
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Healy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-05-28 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,16 +26,25 @@ extra_rdoc_files:
|
|
26
26
|
files:
|
27
27
|
- examples/cell.rb
|
28
28
|
- examples/image.rb
|
29
|
+
- examples/markup.rb
|
29
30
|
- examples/repeating.rb
|
31
|
+
- examples/scaled.rb
|
32
|
+
- examples/scaled_cells.rb
|
33
|
+
- examples/scaled_image.rb
|
30
34
|
- examples/shapes.rb
|
31
35
|
- examples/table.rb
|
36
|
+
- examples/translate.rb
|
32
37
|
- examples/utf8-long.rb
|
33
38
|
- examples/utf8.rb
|
34
|
-
- examples/template.rb
|
35
|
-
- examples/padded_image.rb
|
36
39
|
- lib/pdf
|
37
40
|
- lib/pdf/core.rb
|
38
41
|
- lib/pdf/wrapper.rb
|
42
|
+
- lib/pdf/wrapper
|
43
|
+
- lib/pdf/wrapper/graphics.rb
|
44
|
+
- lib/pdf/wrapper/images.rb
|
45
|
+
- lib/pdf/wrapper/loading.rb
|
46
|
+
- lib/pdf/wrapper/table.rb
|
47
|
+
- lib/pdf/wrapper/text.rb
|
39
48
|
- specs/data
|
40
49
|
- specs/data/google.png
|
41
50
|
- specs/data/iso-2022-jp.txt
|
@@ -46,13 +55,15 @@ files:
|
|
46
55
|
- specs/data/utf8-long.pdf
|
47
56
|
- specs/data/utf8-long.txt
|
48
57
|
- specs/data/utf8.txt
|
58
|
+
- specs/data/windmill.jpg
|
49
59
|
- specs/data/zits.gif
|
50
|
-
- specs/
|
60
|
+
- specs/graphics_spec.rb
|
61
|
+
- specs/image_spec.rb
|
51
62
|
- specs/load_spec.rb
|
52
|
-
- specs/shapes_spec.rb
|
53
|
-
- specs/text_spec.rb
|
54
63
|
- specs/spec_helper.rb
|
55
|
-
- specs/
|
64
|
+
- specs/tables_spec.rb
|
65
|
+
- specs/text_spec.rb
|
66
|
+
- specs/wrapper_spec.rb
|
56
67
|
- Rakefile
|
57
68
|
- README
|
58
69
|
- CHANGELOG
|
@@ -83,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
94
|
requirements: []
|
84
95
|
|
85
96
|
rubyforge_project: pdf-wrapper
|
86
|
-
rubygems_version: 1.
|
97
|
+
rubygems_version: 1.1.1
|
87
98
|
signing_key:
|
88
99
|
specification_version: 2
|
89
100
|
summary: A PDF generating library built on top of cairo
|