pdf-wrapper 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,6 @@ module PDF
19
19
  # TODO: add support for a table footer
20
20
  # - repeating each page, or just at the bottom?
21
21
  # - if it repeats, should it be different on each page? ie. a sum of that pages rows, etc.
22
- # TODO: add support for manually specifying 1 or more column widths
23
22
  # TODO: maybe support for multiple data sets with group headers/footers. useful for subtotals, etc
24
23
 
25
24
  x, y = current_point
@@ -85,6 +84,9 @@ module PDF
85
84
  # TODO: when calculating the min cell width, we basically want the width of the widest character. At the
86
85
  # moment I'm stripping all pango markup tags from the string, which means if any character is made
87
86
  # intentioanlly large, we'll miss it and it might not fit into our table cell.
87
+ # TODO: allow column widths to be set manually
88
+
89
+ # calculate the min and max width of every cell in the table
88
90
  t.cells.each_with_index do |row, row_idx|
89
91
  row.each_with_index do |cell, col_idx|
90
92
  opts = t.options_for(col_idx, row_idx).only(default_text_options.keys)
@@ -93,6 +95,8 @@ module PDF
93
95
  cell.max_width = text_width(cell.data, opts) + (padding * 4)
94
96
  end
95
97
  end
98
+
99
+ # calculate the min and max width of every cell in the headers row
96
100
  if t.headers
97
101
  t.headers.each_with_index do |cell, col_idx|
98
102
  opts = t.options_for(col_idx, :headers).only(default_text_options.keys)
@@ -101,7 +105,12 @@ module PDF
101
105
  cell.max_width = text_width(cell.data, opts) + (padding * 4)
102
106
  end
103
107
  end
108
+
109
+ # let the table decide on the actual widths it will use for each col
104
110
  t.calc_col_widths!
111
+
112
+ # now that we know how wide each column will be, we can calculate the
113
+ # height of every cell in the table
105
114
  t.cells.each_with_index do |row, row_idx|
106
115
  row.each_with_index do |cell, col_idx|
107
116
  opts = t.options_for(col_idx, row_idx).only(default_text_options.keys)
@@ -109,7 +118,11 @@ module PDF
109
118
  cell.height = text_height(cell.data, t.col_width(col_idx) - (padding * 2), opts) + (padding * 2)
110
119
  end
111
120
  end
121
+
122
+ # let the table calculate how high each row is going to be
112
123
  t.calc_row_heights!
124
+
125
+ # perform the same height calcs for the header row if necesary
113
126
  if t.headers
114
127
  t.headers.each_with_index do |cell, col_idx|
115
128
  opts = t.options_for(col_idx, :headers).only(default_text_options.keys)
@@ -147,7 +160,7 @@ module PDF
147
160
  # with optional headings, then pass the object to Wrapper#table
148
161
  #
149
162
  # table = Table.new do |t|
150
- # t.headings = ["Words", "Numbers"]
163
+ # t.headers = ["Words", "Numbers"]
151
164
  # t.data = [['one', 1],
152
165
  # ['two', 2],
153
166
  # ['three',3]]
@@ -167,16 +180,16 @@ module PDF
167
180
  #
168
181
  # For example:
169
182
  #
170
- # table = Table.new do |t|
183
+ # table = Table.new(:font_size => 10) do |t|
171
184
  # t.headers = ["Words", "Numbers"]
172
185
  # t.data = [['one', 1],
173
186
  # ['two', 2],
174
187
  # ['three',3]]
175
- # t.table_options :font_size => 10
176
188
  # t.row_options 0, :color => :green
177
189
  # t.row_options 2, :color => :red
178
190
  # t.col_options 0, :color => :blue
179
191
  # t.cell_options 2, 2, :font_size => 18
192
+ # t.manual_column_width 2, 40
180
193
  # end
181
194
  # pdf.table(table)
182
195
  #
@@ -188,19 +201,17 @@ module PDF
188
201
  # top of the table, and :page for the default.
189
202
  #
190
203
  class Table
191
- attr_reader :cells, :headers
204
+ attr_reader :cells#, :headers
192
205
  attr_accessor :width, :show_headers
193
206
 
194
207
  #
195
- # headers should be a single array
196
- #
197
- # ["first", "second"]
198
- def initialize
208
+ def initialize(opts = {})
199
209
 
200
210
  # default table options
201
- @table_options = {}
211
+ @table_options = opts
202
212
  @col_options = Hash.new({})
203
213
  @row_options = Hash.new({})
214
+ @manual_col_widths = {}
204
215
  @header_options = {}
205
216
  @show_headers = :page
206
217
 
@@ -224,18 +235,40 @@ module PDF
224
235
  end
225
236
  end
226
237
 
227
- # Specify the tables optional column headers.
238
+ # Retrieve or set the table's optional column headers.
228
239
  #
229
- # The single argument should be an array like:
240
+ # With no arguments, the currents headers will be returned
230
241
  #
231
- # [ "col one", "col two"]
232
- def headers=(h)
242
+ # t.headers
243
+ # => ["col one", "col two"]
244
+ #
245
+ # The first argument is an array of text to use as column headers
246
+ #
247
+ # t.headers ["col one", "col two]
248
+ #
249
+ # The optional second argument sets the cell options for the header
250
+ # cells. See PDF::Wrapper#cell for a list of possible options.
251
+ #
252
+ # t.headers ["col one", "col two], :color => :block, :fill_color => :black
253
+ #
254
+ # If the options hash is left unspecified, the default table options will
255
+ # be used.
256
+ #
257
+ def headers(h = nil, opts = {})
233
258
  # TODO: raise an exception of the size of the array does not match the size
234
259
  # of the data row arrays
235
260
  # TODO: ensure h is array-like
261
+ return @headers if h.nil?
236
262
  @headers = h.collect do |str|
237
263
  Wrapper::Cell.new(str)
238
264
  end
265
+ @header_options = opts
266
+ end
267
+
268
+ def headers=(h)
269
+ # TODO: remove this method at some point. Deprecation started on 10th August 2008.
270
+ warn "WARNING: Table#headers=() is deprecated, headers should now be set along with header options using Table#headers()"
271
+ headers h
239
272
  end
240
273
 
241
274
  # access a particular cell at location x, y
@@ -245,14 +278,24 @@ module PDF
245
278
 
246
279
  # Set or retrieve options that apply to every cell in the table.
247
280
  # For a list of valid options, see Wrapper#cell.
281
+ #
282
+ # WARNING. This method is deprecated. Table options should be passed to the
283
+ # PDF::Wrapper::Table constructor instead
248
284
  def table_options(opts = nil)
285
+ # TODO: remove this method at some point. Deprecation started on 10th August 2008.
286
+ warn "WARNING: Table#table_options() is deprecated, please see the documentation for PDF::Wrapper::Table"
249
287
  @table_options = @table_options.merge(opts) if opts
250
288
  @table_options
251
289
  end
252
290
 
253
291
  # set or retrieve options that apply to header cells
254
292
  # For a list of valid options, see Wrapper#cell.
293
+ #
294
+ # WARNING. This method is deprecated. Header options should be passed to the
295
+ # PDF::Wrapper::Table#headers method instead
255
296
  def header_options(opts = nil)
297
+ # TODO: remove this method at some point. Deprecation started on 10th August 2008.
298
+ warn "WARNING: Table#header_options() is deprecated, please see the documentation for PDF::Wrapper::Table"
256
299
  @header_options = @header_options.merge(opts) if opts
257
300
  @header_options
258
301
  end
@@ -282,6 +325,25 @@ module PDF
282
325
  self
283
326
  end
284
327
 
328
+ # Manually set the width for 1 or more columns
329
+ #
330
+ # <tt>spec</tt>:: Which columns to set the width for. :odd, :even, a range, an Array of numbers or a number
331
+ #
332
+ def manual_col_width(spec, width)
333
+ width = width.to_f
334
+ each_column do |col_idx|
335
+ if (spec == :even && (col_idx % 2) == 0) ||
336
+ (spec == :odd && (col_idx % 2) == 1) ||
337
+ (spec.class == Range && spec.include?(col_idx)) ||
338
+ (spec.class == Array && spec.include?(col_idx)) ||
339
+ (spec.respond_to?(:to_i) && spec.to_i == col_idx)
340
+
341
+ @manual_col_widths[col_idx] = width
342
+ end
343
+ end
344
+ self
345
+ end
346
+
285
347
  # set options that apply to 1 or more rows
286
348
  # For a list of valid options, see Wrapper#cell.
287
349
  # <tt>spec</tt>:: Which columns to add the options to. :odd, :even, a range, an Array of numbers or a number
@@ -301,7 +363,7 @@ module PDF
301
363
 
302
364
  # calculate the combined options for a particular cell
303
365
  #
304
- # To get the options for a regular cell, use numbers to refernce the exact cell:
366
+ # To get the options for a regular cell, use numbers to reference the exact cell:
305
367
  #
306
368
  # options_for(3, 3)
307
369
  #
@@ -374,7 +436,7 @@ module PDF
374
436
 
375
437
  private
376
438
 
377
- # the main smarts behind deciding on the width of each column. If possible,
439
+ # the main smarts behind deciding on the width of each column. If possible,
378
440
  # each cell will get the maximum amount of space it wants. If not, some
379
441
  # negotiation happens to find the best possible set of widths.
380
442
  def calc_column_widths
@@ -395,6 +457,13 @@ module PDF
395
457
  end
396
458
  end
397
459
 
460
+ # override the min and max col widths with manual ones where appropriate
461
+ # freeze the values so that the algorithm that adjusts the widths
462
+ # leaves them untouched
463
+ @manual_col_widths.each { |key, val| val.freeze }
464
+ max_col_widths.merge! @manual_col_widths
465
+ min_col_widths.merge! @manual_col_widths
466
+
398
467
  if min_col_widths.values.sum > self.width
399
468
  raise RuntimeError, "table content cannot fit into a table width of #{self.width}"
400
469
  end
@@ -414,18 +483,24 @@ module PDF
414
483
  col_widths
415
484
  end
416
485
 
417
- # ceck to ensure every cell has a minimum and maximum cell width defined
486
+ # check to ensure every cell has a minimum and maximum cell width defined
418
487
  def check_cell_widths
419
488
  @cells.each do |row|
420
- row.each do |cell|
489
+ row.each_with_index do |cell, col_idx|
421
490
  raise "Every cell must have a min_width defined before being rendered to a document" if cell.min_width.nil?
422
491
  raise "Every cell must have a max_width defined before being rendered to a document" if cell.max_width.nil?
492
+ if @manual_col_widths[col_idx] && cell.min_width > @manual_col_widths[col_idx]
493
+ raise "Manual width for col #{col_idx} is too low"
494
+ end
423
495
  end
424
496
  end
425
497
  if @headers
426
- @headers.each do |cell|
498
+ @headers.each_with_index do |cell, col_idx|
427
499
  raise "Every header cell must have a min_width defined before being rendered to a document" if cell.min_width.nil?
428
500
  raise "Every header cell must have a max_width defined before being rendered to a document" if cell.max_width.nil?
501
+ if @manual_col_widths[col_idx] && cell.min_width > @manual_col_widths[col_idx]
502
+ raise "Manual width for col #{col_idx} is too low"
503
+ end
429
504
  end
430
505
  end
431
506
  end
@@ -457,9 +532,9 @@ module PDF
457
532
  # if the widths of every column are less than the total width
458
533
  # of the table, grow them to make use of it.
459
534
  #
460
- # col_widths - the cuurect hash of widths for each column index
535
+ # col_widths - the current hash of widths for each column index
461
536
  # max_col_widths - the maximum width each column desires
462
- # pas_max - can the width of a colum grow beyond its maximum desired
537
+ # past_max - can the width of a colum grow beyond its maximum desired
463
538
  def grow_col_widths(col_widths, max_col_widths, past_max = false)
464
539
  loop do
465
540
  each_column do |idx|
@@ -1,9 +1,36 @@
1
1
  module PDF
2
2
  class Wrapper
3
3
 
4
- # change the default font size
4
+ # Change the default font size
5
+ #
6
+ # If no block is provided, the change is permanent. If a block
7
+ # is provided, the change will revert at the end of the block
8
+ #
9
+ # Permanant change:
10
+ #
11
+ # pdf.font_size 10
12
+ #
13
+ # Temporary change:
14
+ #
15
+ # pdf.font_size 20
16
+ # pdf.text "This text is size 20"
17
+ # pdf.font_size(10) do
18
+ # pdf.text "This text is size 20"
19
+ # end
20
+ # pdf.text "This text is size 20"
21
+ #
5
22
  def font_size(size)
6
- @default_font_size = size.to_i unless size.nil?
23
+ new_size = size.to_i
24
+ raise ArgumentError, 'font size must be > 0' if new_size <= 0
25
+
26
+ if block_given?
27
+ orig_size = @default_font_size
28
+ @default_font_size = new_size
29
+ yield
30
+ @default_font_size = orig_size
31
+ else
32
+ @default_font_size = new_size
33
+ end
7
34
  end
8
35
  alias font_size= font_size
9
36
 
@@ -65,7 +92,7 @@ module PDF
65
92
  color(options[:color]) if options[:color]
66
93
 
67
94
  # draw the context on our cairo layout
68
- render_layout(layout, options[:padding], options[:padding], texth, :auto_new_page => false)
95
+ render_layout(layout, options[:padding], options[:padding], texth)
69
96
  end
70
97
 
71
98
  end
@@ -74,7 +101,7 @@ module PDF
74
101
  # Write text to the page
75
102
  #
76
103
  # By default the text will be rendered using all the space within the margins and using
77
- # the default font styling set by default_font(), default_font_size, etc
104
+ # the default font styling set by font(), font_size, etc
78
105
  #
79
106
  # There is no way to place a bottom bound (or height) onto the text. Text will wrap as
80
107
  # necessary and take all the room it needs. For finer grained control of text boxes, see the
@@ -110,7 +137,7 @@ module PDF
110
137
  # The format is vaguely XML-like.
111
138
  #
112
139
  # Bold: "Some of this text is <b>bold</b>."
113
- # Italics: "Some of this text is in <b>italics</b>."
140
+ # Italics: "Some of this text is in <i>italics</i>."
114
141
  # Strikethrough: "My name is <s>Bob</s>James."
115
142
  # Monospace Font: "Code:\n<tt>puts 1</tt>."
116
143
  #
@@ -118,6 +145,7 @@ module PDF
118
145
  #
119
146
  # Big and Bold: Some of this text is <span weight="bold" font_desc="20">bold</span>.
120
147
  # Stretched: Some of this text is <span stretch="extraexpanded">funny looking</span>.
148
+ #
121
149
  def text(str, opts={})
122
150
  # TODO: add converters from various markup languages to pango markup. (markdown, textile, etc)
123
151
  # TODO: add a wrap option so wrapping can be disabled
@@ -141,7 +169,7 @@ module PDF
141
169
  color(options[:color]) if options[:color]
142
170
 
143
171
  # draw the context on our cairo layout
144
- y = render_layout(layout, options[:left], options[:top], points_to_bottom_margin(options[:top]), :auto_new_page => true)
172
+ y = render_layout(layout, options[:left], options[:top])
145
173
 
146
174
  move_to(options[:left], y)
147
175
  end
@@ -175,7 +203,7 @@ module PDF
175
203
  private
176
204
 
177
205
  # takes a string and a range of options and creates a pango layout for us. Pango
178
- # does all the hard work of calculating text layout, wrapping, fonts, sizes,
206
+ # does all the hard work of calculating text layout, wrapping, fonts, sizes,
179
207
  # direction and more. Thank $diety.
180
208
  #
181
209
  # The string should be encoded using utf-8. If you get unexpected characters in the
@@ -287,13 +315,18 @@ module PDF
287
315
  # based on a function of the same name found in the text2.rb sample file
288
316
  # distributed with rcairo - it's still black magic to me and has a few edge
289
317
  # cases where it doesn't work too well. Needs to be improved.
290
- def render_layout(layout, x, y, h, opts = {})
318
+ #
319
+ # If h is specified, lines of text will be rendered up to that height, and
320
+ # the rest will be ignored.
321
+ #
322
+ # If h is nil, lines will be rendered until the bottom margin is hit, then
323
+ # a new page will be started and lines will continue being rendered at the
324
+ # top of the new page.
325
+ def render_layout(layout, x, y, h = nil)
291
326
  # we can't use context.show_pango_layout, as that won't start
292
327
  # a new page if the layout hits the bottom margin. Instead,
293
328
  # we iterate over each line of text in the layout and add it to
294
329
  # the canvas, page breaking as necessary
295
- options = {:auto_new_page => true }
296
- options.merge!(opts)
297
330
 
298
331
  offset = 0
299
332
  baseline = 0
@@ -308,17 +341,15 @@ module PDF
308
341
  baseline = iter.baseline / Pango::SCALE
309
342
  linex = logical_rect.x / Pango::SCALE
310
343
 
311
- if baseline - offset >= h
312
- # our text is using the maximum amount of vertical space we want it to
313
- if options[:auto_new_page]
314
- # create a new page and we can continue adding text
315
- offset = baseline
316
- start_new_page
317
- else
318
- # the user doesn't want us to continue on the next page, so
319
- # stop adding lines to the canvas
320
- break
321
- end
344
+ if h && baseline - offset >= h
345
+ # the user doesn't want us to continue on the next page, so
346
+ # stop adding lines to the canvas
347
+ break
348
+ elsif h.nil? && (y + baseline - offset + spacing) >= self.absolute_bottom_margin
349
+ # create a new page and we can continue adding text
350
+ offset = baseline
351
+ start_new_page
352
+ y = self.y
322
353
  end
323
354
 
324
355
  # move to the start of this line
@@ -3,14 +3,17 @@
3
3
  require File.dirname(__FILE__) + '/spec_helper'
4
4
 
5
5
  context "The PDF::Wrapper class" do
6
+
7
+ before(:each) { create_pdf }
8
+
6
9
  specify "should be able to draw a single line onto the canvas" do
7
10
  x0 = y0 = 100
8
11
  x1 = y1 = 200
9
- pdf = PDF::Wrapper.new
10
- pdf.line(x0,y0,x1,y1)
12
+ @pdf.line(x0,y0,x1,y1)
13
+ @pdf.finish
11
14
 
12
15
  receiver = PDF::Reader::RegisterReceiver.new
13
- reader = PDF::Reader.string(pdf.render, receiver)
16
+ reader = PDF::Reader.string(@output.string, receiver)
14
17
 
15
18
  # the begin_new_subpath command specifies the start of the line, append line specifies the end
16
19
  receiver.count(:begin_new_subpath).should eql(1)
@@ -23,11 +26,11 @@ context "The PDF::Wrapper class" do
23
26
  x0 = y0 = 100
24
27
  x1 = y1 = 200
25
28
  width = 5
26
- pdf = PDF::Wrapper.new
27
- pdf.line(x0,y0,x1,y1, :line_width => width)
29
+ @pdf.line(x0,y0,x1,y1, :line_width => width)
30
+ @pdf.finish
28
31
 
29
32
  receiver = PDF::Reader::RegisterReceiver.new
30
- reader = PDF::Reader.string(pdf.render, receiver)
33
+ reader = PDF::Reader.string(@output.string, receiver)
31
34
 
32
35
  # the begin_new_subpath command specifies the start of the line, append line specifies the end
33
36
  receiver.count(:set_line_width).should eql(1)
@@ -43,11 +46,11 @@ context "The PDF::Wrapper class" do
43
46
  specify "should be able to draw an empty rectangle onto the canvas" do
44
47
  x = y = 100
45
48
  w = h = 200
46
- pdf = PDF::Wrapper.new
47
- pdf.rectangle(x,y,w,h)
49
+ @pdf.rectangle(x,y,w,h)
50
+ @pdf.finish
48
51
 
49
52
  receiver = PDF::Reader::RegisterReceiver.new
50
- reader = PDF::Reader.string(pdf.render, receiver)
53
+ reader = PDF::Reader.string(@output.string, receiver)
51
54
 
52
55
  # the begin_new_subpath command specifies the start of the line, append line specifies the end
53
56
  callbacks = receiver.all(:append_rectangle)
@@ -61,11 +64,11 @@ context "The PDF::Wrapper class" do
61
64
  x = y = 100
62
65
  w = h = 200
63
66
  width = 5
64
- pdf = PDF::Wrapper.new
65
- pdf.rectangle(x,y,w,h, :line_width => width)
67
+ @pdf.rectangle(x,y,w,h, :line_width => width)
68
+ @pdf.finish
66
69
 
67
70
  receiver = PDF::Reader::RegisterReceiver.new
68
- reader = PDF::Reader.string(pdf.render, receiver)
71
+ reader = PDF::Reader.string(@output.string, receiver)
69
72
 
70
73
  # ensure the line width was set correctly
71
74
  receiver.count(:set_line_width).should eql(1)
@@ -85,10 +88,10 @@ context "The PDF::Wrapper class" do
85
88
  x = y = 100
86
89
  w = h = 200
87
90
  pdf = PDF::Wrapper.new
88
- pdf.rectangle(x,y,w,h, :fill_color => :red)
91
+ @pdf.rectangle(x,y,w,h, :fill_color => :red)
89
92
 
90
93
  receiver = PDF::Reader::RegisterReceiver.new
91
- reader = PDF::Reader.string(pdf.render, receiver)
94
+ reader = PDF::Reader.string(@pdf.render, receiver)
92
95
 
93
96
  # TODO: test for the appropriate pattern of callbacks
94
97
  end
@@ -101,10 +104,10 @@ context "The PDF::Wrapper class" do
101
104
  w = h = 200
102
105
  r = 5
103
106
  pdf = PDF::Wrapper.new
104
- pdf.rectangle(x,y,w,h,:radius => r)
107
+ @pdf.rectangle(x,y,w,h,:radius => r)
105
108
 
106
109
  receiver = PDF::Reader::RegisterReceiver.new
107
- reader = PDF::Reader.string(pdf.render, receiver)
110
+ reader = PDF::Reader.string(@pdf.render, receiver)
108
111
 
109
112
  # TODO: test for the appropriate pattern of callbacks
110
113
  end
@@ -118,10 +121,10 @@ context "The PDF::Wrapper class" do
118
121
  r = 5
119
122
  w = 5
120
123
  pdf = PDF::Wrapper.new
121
- pdf.rounded_rectangle(x,y,w,h, :radius => r, :line_width => w)
124
+ @pdf.rounded_rectangle(x,y,w,h, :radius => r, :line_width => w)
122
125
 
123
126
  receiver = PDF::Reader::RegisterReceiver.new
124
- reader = PDF::Reader.string(pdf.render, receiver)
127
+ reader = PDF::Reader.string(@pdf.render, receiver)
125
128
 
126
129
  # TODO: test for the appropriate pattern of callbacks
127
130
  end
@@ -134,10 +137,10 @@ context "The PDF::Wrapper class" do
134
137
  w = h = 200
135
138
  r = 5
136
139
  pdf = PDF::Wrapper.new
137
- pdf.rounded_rectangle(x,y,w,h, :radius => r, :fill_color => :red)
140
+ @pdf.rounded_rectangle(x,y,w,h, :radius => r, :fill_color => :red)
138
141
 
139
142
  receiver = PDF::Reader::RegisterReceiver.new
140
- reader = PDF::Reader.string(pdf.render, receiver)
143
+ reader = PDF::Reader.string(@pdf.render, receiver)
141
144
 
142
145
  # TODO: test for the appropriate pattern of callbacks
143
146
  end
@@ -150,10 +153,10 @@ context "The PDF::Wrapper class" do
150
153
  y = 200
151
154
  r = 5
152
155
  pdf = PDF::Wrapper.new
153
- pdf.circle(x,y,r)
156
+ @pdf.circle(x,y,r)
154
157
 
155
158
  receiver = PDF::Reader::RegisterReceiver.new
156
- reader = PDF::Reader.string(pdf.render, receiver)
159
+ reader = PDF::Reader.string(@pdf.render, receiver)
157
160
 
158
161
  # TODO: test for the appropriate pattern of callbacks
159
162
  end
@@ -167,10 +170,10 @@ context "The PDF::Wrapper class" do
167
170
  r = 5
168
171
  w = 5
169
172
  pdf = PDF::Wrapper.new
170
- pdf.circle(x,y,r, :line_width => w)
173
+ @pdf.circle(x,y,r, :line_width => w)
171
174
 
172
175
  receiver = PDF::Reader::RegisterReceiver.new
173
- reader = PDF::Reader.string(pdf.render, receiver)
176
+ reader = PDF::Reader.string(@pdf.render, receiver)
174
177
 
175
178
  # TODO: test for the appropriate pattern of callbacks
176
179
  end
@@ -183,10 +186,10 @@ context "The PDF::Wrapper class" do
183
186
  y = 200
184
187
  r = 5
185
188
  pdf = PDF::Wrapper.new
186
- pdf.circle(x,y,r, :fill_color => :red)
189
+ @pdf.circle(x,y,r, :fill_color => :red)
187
190
 
188
191
  receiver = PDF::Reader::RegisterReceiver.new
189
- reader = PDF::Reader.string(pdf.render, receiver)
192
+ reader = PDF::Reader.string(@pdf.render, receiver)
190
193
 
191
194
  # TODO: test for the appropriate pattern of callbacks
192
195
  end