prawn 1.0.0.rc2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +9 -0
  3. data/COPYING +2 -2
  4. data/Gemfile +8 -15
  5. data/LICENSE +1 -1
  6. data/Rakefile +25 -16
  7. data/data/images/16bit.alpha +0 -0
  8. data/data/images/16bit.color +0 -0
  9. data/data/images/dice.alpha +0 -0
  10. data/data/images/dice.color +0 -0
  11. data/data/images/indexed_color.dat +0 -0
  12. data/data/images/indexed_color.png +0 -0
  13. data/data/images/license.md +8 -0
  14. data/data/images/page_white_text.alpha +0 -0
  15. data/data/images/page_white_text.color +0 -0
  16. data/lib/prawn.rb +85 -23
  17. data/lib/prawn/document.rb +134 -116
  18. data/lib/prawn/document/bounding_box.rb +33 -4
  19. data/lib/prawn/document/column_box.rb +18 -6
  20. data/lib/prawn/document/graphics_state.rb +11 -74
  21. data/lib/prawn/document/internals.rb +24 -23
  22. data/lib/prawn/document/span.rb +12 -10
  23. data/lib/prawn/encoding.rb +8 -9
  24. data/lib/prawn/errors.rb +13 -32
  25. data/lib/prawn/font.rb +137 -105
  26. data/lib/prawn/font/afm.rb +76 -32
  27. data/lib/prawn/font/dfont.rb +4 -3
  28. data/lib/prawn/font/ttf.rb +33 -25
  29. data/lib/prawn/font_metric_cache.rb +47 -0
  30. data/lib/prawn/graphics.rb +177 -57
  31. data/lib/prawn/graphics/cap_style.rb +4 -3
  32. data/lib/prawn/graphics/color.rb +5 -4
  33. data/lib/prawn/graphics/dash.rb +53 -31
  34. data/lib/prawn/graphics/join_style.rb +9 -7
  35. data/lib/prawn/graphics/patterns.rb +4 -15
  36. data/lib/prawn/graphics/transformation.rb +10 -9
  37. data/lib/prawn/graphics/transparency.rb +3 -1
  38. data/lib/prawn/{layout/grid.rb → grid.rb} +72 -54
  39. data/lib/prawn/image_handler.rb +42 -0
  40. data/lib/prawn/images.rb +58 -54
  41. data/lib/prawn/images/image.rb +6 -22
  42. data/lib/prawn/images/jpg.rb +20 -14
  43. data/lib/prawn/images/png.rb +58 -121
  44. data/lib/prawn/layout.rb +12 -15
  45. data/lib/prawn/measurement_extensions.rb +10 -6
  46. data/lib/prawn/measurements.rb +27 -21
  47. data/lib/prawn/outline.rb +108 -147
  48. data/lib/prawn/repeater.rb +10 -8
  49. data/lib/prawn/security.rb +59 -40
  50. data/lib/prawn/security/arcfour.rb +52 -0
  51. data/lib/prawn/soft_mask.rb +4 -4
  52. data/lib/prawn/stamp.rb +5 -3
  53. data/lib/prawn/table.rb +83 -60
  54. data/lib/prawn/table/cell.rb +17 -21
  55. data/lib/prawn/table/cell/image.rb +2 -3
  56. data/lib/prawn/table/cell/in_table.rb +8 -2
  57. data/lib/prawn/table/cell/span_dummy.rb +5 -0
  58. data/lib/prawn/table/cell/subtable.rb +3 -2
  59. data/lib/prawn/table/cell/text.rb +14 -12
  60. data/lib/prawn/table/cells.rb +58 -14
  61. data/lib/prawn/table/column_width_calculator.rb +61 -0
  62. data/lib/prawn/text.rb +27 -26
  63. data/lib/prawn/text/box.rb +12 -6
  64. data/lib/prawn/text/formatted.rb +5 -4
  65. data/lib/prawn/text/formatted/arranger.rb +290 -0
  66. data/lib/prawn/text/formatted/box.rb +85 -57
  67. data/lib/prawn/text/formatted/fragment.rb +11 -11
  68. data/lib/prawn/text/formatted/line_wrap.rb +266 -0
  69. data/lib/prawn/text/formatted/parser.rb +11 -4
  70. data/lib/prawn/text/formatted/wrap.rb +156 -0
  71. data/lib/prawn/utilities.rb +5 -3
  72. data/manual/document_and_page_options/document_and_page_options.rb +2 -1
  73. data/manual/document_and_page_options/metadata.rb +3 -3
  74. data/manual/document_and_page_options/page_size.rb +2 -2
  75. data/manual/document_and_page_options/print_scaling.rb +20 -0
  76. data/manual/example_file.rb +2 -7
  77. data/manual/example_helper.rb +62 -81
  78. data/manual/graphics/common_lines.rb +2 -0
  79. data/manual/graphics/helper.rb +11 -4
  80. data/manual/graphics/stroke_dash.rb +19 -14
  81. data/manual/manual/cover.rb +16 -0
  82. data/manual/manual/manual.rb +1 -5
  83. data/manual/text/fallback_fonts.rb +4 -4
  84. data/manual/text/formatted_text.rb +5 -5
  85. data/manual/text/inline.rb +2 -4
  86. data/manual/text/registering_families.rb +12 -12
  87. data/manual/text/single_usage.rb +4 -4
  88. data/manual/text/text.rb +0 -2
  89. data/prawn.gemspec +21 -13
  90. data/spec/acceptance/png.rb +23 -0
  91. data/spec/annotations_spec.rb +16 -32
  92. data/spec/bounding_box_spec.rb +22 -5
  93. data/spec/cell_spec.rb +49 -5
  94. data/spec/column_box_spec.rb +32 -0
  95. data/spec/destinations_spec.rb +5 -5
  96. data/spec/document_spec.rb +112 -118
  97. data/spec/extensions/encoding_helpers.rb +5 -2
  98. data/spec/font_metric_cache_spec.rb +52 -0
  99. data/spec/font_spec.rb +121 -120
  100. data/spec/formatted_text_arranger_spec.rb +24 -24
  101. data/spec/formatted_text_box_spec.rb +31 -32
  102. data/spec/formatted_text_fragment_spec.rb +2 -2
  103. data/spec/graphics_spec.rb +63 -45
  104. data/spec/grid_spec.rb +24 -13
  105. data/spec/image_handler_spec.rb +54 -0
  106. data/spec/images_spec.rb +34 -21
  107. data/spec/inline_formatted_text_parser_spec.rb +69 -20
  108. data/spec/jpg_spec.rb +3 -3
  109. data/spec/line_wrap_spec.rb +25 -14
  110. data/spec/measurement_units_spec.rb +5 -5
  111. data/spec/outline_spec.rb +68 -64
  112. data/spec/png_spec.rb +15 -18
  113. data/spec/reference_spec.rb +2 -82
  114. data/spec/repeater_spec.rb +1 -1
  115. data/spec/security_spec.rb +41 -9
  116. data/spec/soft_mask_spec.rb +0 -40
  117. data/spec/span_spec.rb +6 -11
  118. data/spec/spec_helper.rb +20 -2
  119. data/spec/stamp_spec.rb +19 -20
  120. data/spec/stroke_styles_spec.rb +31 -13
  121. data/spec/table/span_dummy_spec.rb +17 -0
  122. data/spec/table_spec.rb +268 -43
  123. data/spec/text_at_spec.rb +13 -27
  124. data/spec/text_box_spec.rb +35 -30
  125. data/spec/text_spec.rb +56 -40
  126. data/spec/transparency_spec.rb +5 -5
  127. metadata +214 -217
  128. data/README.md +0 -98
  129. data/data/fonts/Action Man.dfont +0 -0
  130. data/data/fonts/Activa.ttf +0 -0
  131. data/data/fonts/Chalkboard.ttf +0 -0
  132. data/data/fonts/DejaVuSans.ttf +0 -0
  133. data/data/fonts/Dustismo_Roman.ttf +0 -0
  134. data/data/fonts/comicsans.ttf +0 -0
  135. data/data/fonts/gkai00mp.ttf +0 -0
  136. data/data/images/16bit.dat +0 -0
  137. data/data/images/barcode_issue.png +0 -0
  138. data/data/images/dice.dat +0 -0
  139. data/data/images/page_white_text.dat +0 -0
  140. data/data/images/rails.dat +0 -0
  141. data/data/images/rails.png +0 -0
  142. data/lib/prawn/compatibility.rb +0 -87
  143. data/lib/prawn/core.rb +0 -87
  144. data/lib/prawn/core/annotations.rb +0 -61
  145. data/lib/prawn/core/byte_string.rb +0 -9
  146. data/lib/prawn/core/destinations.rb +0 -90
  147. data/lib/prawn/core/document_state.rb +0 -79
  148. data/lib/prawn/core/literal_string.rb +0 -16
  149. data/lib/prawn/core/name_tree.rb +0 -177
  150. data/lib/prawn/core/object_store.rb +0 -320
  151. data/lib/prawn/core/page.rb +0 -212
  152. data/lib/prawn/core/pdf_object.rb +0 -125
  153. data/lib/prawn/core/reference.rb +0 -119
  154. data/lib/prawn/core/text.rb +0 -268
  155. data/lib/prawn/core/text/formatted/arranger.rb +0 -294
  156. data/lib/prawn/core/text/formatted/line_wrap.rb +0 -288
  157. data/lib/prawn/core/text/formatted/wrap.rb +0 -153
  158. data/lib/prawn/document/page_geometry.rb +0 -136
  159. data/lib/prawn/document/snapshot.rb +0 -89
  160. data/manual/manual/foreword.rb +0 -13
  161. data/manual/templates/full_template.rb +0 -23
  162. data/manual/templates/page_template.rb +0 -47
  163. data/manual/templates/templates.rb +0 -26
  164. data/manual/text/group.rb +0 -29
  165. data/spec/name_tree_spec.rb +0 -112
  166. data/spec/object_store_spec.rb +0 -170
  167. data/spec/pdf_object_spec.rb +0 -172
  168. data/spec/snapshot_spec.rb +0 -186
  169. data/spec/template_spec.rb +0 -351
@@ -8,6 +8,7 @@
8
8
 
9
9
  module Prawn
10
10
  class Document
11
+ # @group Stable API
11
12
 
12
13
  # :call-seq:
13
14
  # bounding_box(point, options={}, &block)
@@ -188,10 +189,21 @@ module Prawn
188
189
 
189
190
  parent_box = @bounding_box
190
191
 
192
+ original_ypos = y
193
+
191
194
  init_block.call(parent_box)
192
195
 
193
196
  self.y = @bounding_box.absolute_top
194
197
  user_block.call
198
+
199
+ # If the user actions did not modify the y position
200
+ # restore the original y position before the bounding
201
+ # box was created.
202
+
203
+ if y == @bounding_box.absolute_top
204
+ self.y = original_ypos
205
+ end
206
+
195
207
  unless options[:hold_position] || @bounding_box.stretchy?
196
208
  self.y = @bounding_box.absolute_bottom
197
209
  end
@@ -208,7 +220,7 @@ module Prawn
208
220
  #
209
221
  class BoundingBox
210
222
 
211
- def initialize(document, parent, point, options={}) #:nodoc:
223
+ def initialize(document, parent, point, options={}) # @private
212
224
  unless options[:width]
213
225
  raise ArgumentError, "BoundingBox needs the :width option to be set"
214
226
  end
@@ -222,15 +234,22 @@ module Prawn
222
234
  @stretched_height = nil
223
235
  end
224
236
 
237
+ # @private
238
+
225
239
  attr_reader :document, :parent
240
+
241
+ # @private
226
242
  # The current indentation of the left side of the bounding box.
227
243
  attr_reader :total_left_padding
244
+
245
+ # @private
228
246
  # The current indentation of the right side of the bounding box.
229
247
  attr_reader :total_right_padding
230
248
 
231
249
  # The translated origin (x,y-height) which describes the location
232
250
  # of the bottom left corner of the bounding box
233
251
  #
252
+ # @private
234
253
  def anchor
235
254
  [@x, @y - height]
236
255
  end
@@ -261,6 +280,7 @@ module Prawn
261
280
  # text "indented on both sides"
262
281
  # end
263
282
  #
283
+ # @private
264
284
  def indent(left_padding, right_padding = 0, &block)
265
285
  add_left_padding(left_padding)
266
286
  add_right_padding(right_padding)
@@ -271,6 +291,7 @@ module Prawn
271
291
  end
272
292
 
273
293
  # Increase the left padding of the bounding box.
294
+ # @private
274
295
  def add_left_padding(left_padding)
275
296
  @total_left_padding += left_padding
276
297
  @x += left_padding
@@ -278,6 +299,7 @@ module Prawn
278
299
  end
279
300
 
280
301
  # Decrease the left padding of the bounding box.
302
+ # @private
281
303
  def subtract_left_padding(left_padding)
282
304
  @total_left_padding -= left_padding
283
305
  @x -= left_padding
@@ -285,12 +307,14 @@ module Prawn
285
307
  end
286
308
 
287
309
  # Increase the right padding of the bounding box.
310
+ # @private
288
311
  def add_right_padding(right_padding)
289
312
  @total_right_padding += right_padding
290
313
  @width -= right_padding
291
314
  end
292
315
 
293
316
  # Decrease the right padding of the bounding box.
317
+ # @private
294
318
  def subtract_right_padding(right_padding)
295
319
  @total_right_padding -= right_padding
296
320
  @width += right_padding
@@ -441,15 +465,19 @@ module Prawn
441
465
  end
442
466
 
443
467
  # an alias for absolute_left
468
+ # @private
444
469
  def left_side
445
470
  absolute_left
446
471
  end
447
472
 
448
473
  # an alias for absolute_right
474
+ # @private
449
475
  def right_side
450
476
  absolute_right
451
477
  end
452
478
 
479
+ # @group Extension API
480
+
453
481
  # Moves to the top of the next page of the document, starting a new page
454
482
  # if necessary.
455
483
  #
@@ -461,9 +489,6 @@ module Prawn
461
489
  end
462
490
  end
463
491
 
464
-
465
- alias_method :update_height, :height
466
-
467
492
  # Returns +false+ when the box has a defined height, +true+ when the height
468
493
  # is being calculated on the fly based on the current vertical position.
469
494
  #
@@ -482,9 +507,12 @@ module Prawn
482
507
  end
483
508
  end
484
509
 
510
+ alias_method :update_height, :height
511
+
485
512
  # Returns a deep copy of these bounds (including all parent bounds but
486
513
  # not copying the reference to the Document).
487
514
  #
515
+ # @private
488
516
  def deep_copy
489
517
  copy = dup
490
518
  # Deep-copy the parent bounds
@@ -499,6 +527,7 @@ module Prawn
499
527
  # context of the given +document+. Does *not* set the bounds of the
500
528
  # document to the resulting BoundingBox, only returns it.
501
529
  #
530
+ # @private
502
531
  def self.restore_deep_copy(bounds, document)
503
532
  bounds.instance_variable_set("@document", document)
504
533
  bounds
@@ -3,23 +3,31 @@
3
3
  # column_box.rb: Extends BoundingBox to allow for columns of text
4
4
  #
5
5
  # Author Paul Ostazeski.
6
+ #
7
+ # This is free software. Please see the LICENSE and COPYING files for details.
8
+
9
+ require_relative "bounding_box"
6
10
 
7
- require "prawn/document/bounding_box"
8
11
  module Prawn
9
12
  class Document
10
13
 
14
+ # @group Experimental API
15
+
11
16
  # A column box is a bounding box with the additional property that when
12
17
  # text flows past the bottom, it will wrap first to another column on the
13
18
  # same page, and only flow to the next page when all the columns are
14
19
  # filled.
15
20
  #
16
21
  # column_box accepts the same parameters as bounding_box, as well as the
17
- # number of :columns and a :spacer (in points) between columns.
22
+ # number of :columns and a :spacer (in points) between columns. If resetting
23
+ # the top margin is desired on a new page (e.g. to allow for initial page
24
+ # wide column titles) the option :reflow_margins => true can be set.
18
25
  #
19
- # Defaults are :columns = 3 and :spacer = font_size
26
+ # Defaults are :columns = 3, :spacer = font_size, and
27
+ # :reflow_margins => false
20
28
  #
21
29
  # Under PDF::Writer, "spacer" was known as "gutter"
22
- #
30
+ #
23
31
  def column_box(*args, &block)
24
32
  init_column_box(block) do |parent_box|
25
33
  map_to_absolute!(args[0])
@@ -40,7 +48,7 @@ module Prawn
40
48
 
41
49
  @bounding_box = parent_box
42
50
  end
43
-
51
+
44
52
  # Implements the necessary functionality to allow Document#column_box to
45
53
  # work.
46
54
  #
@@ -51,6 +59,7 @@ module Prawn
51
59
  @columns = options[:columns] || 3
52
60
  @spacer = options[:spacer] || @document.font_size
53
61
  @current_column = 0
62
+ @reflow_margins = options[:reflow_margins]
54
63
  end
55
64
 
56
65
  # The column width, not the width of the whole box,
@@ -99,10 +108,13 @@ module Prawn
99
108
 
100
109
  # Moves to the next column or starts a new page if currently positioned at
101
110
  # the rightmost column.
102
- def move_past_bottom
111
+ def move_past_bottom
103
112
  @current_column = (@current_column + 1) % @columns
104
113
  @document.y = @y
105
114
  if 0 == @current_column
115
+ if @reflow_margins
116
+ @y = @parent.absolute_top
117
+ end
106
118
  @document.start_new_page
107
119
  end
108
120
  end
@@ -8,71 +8,8 @@
8
8
  #
9
9
 
10
10
  module Prawn
11
- class GraphicStateStack
12
- attr_accessor :stack
13
-
14
- def initialize(previous_state = nil)
15
- self.stack = [GraphicState.new(previous_state)]
16
- end
17
-
18
- def save_graphic_state(graphic_state = nil)
19
- stack.push(GraphicState.new(graphic_state || current_state))
20
- end
21
-
22
- def restore_graphic_state
23
- if stack.empty?
24
- raise Prawn::Errors::EmptyGraphicStateStack,
25
- "\n You have reached the end of the graphic state stack"
26
- end
27
- stack.pop
28
- end
29
-
30
- def current_state
31
- stack.last
32
- end
33
-
34
- def present?
35
- stack.size > 0
36
- end
37
-
38
- def empty?
39
- stack.empty?
40
- end
41
-
42
- end
43
-
44
- class GraphicState
45
- attr_accessor :color_space, :dash, :cap_style, :join_style, :line_width, :fill_color, :stroke_color
46
-
47
- def initialize(previous_state = nil)
48
- @color_space = previous_state ? previous_state.color_space.dup : {}
49
- @fill_color = previous_state ? previous_state.fill_color : "000000"
50
- @stroke_color = previous_state ? previous_state.stroke_color : "000000"
51
- @dash = previous_state ? previous_state.dash : { :dash => nil, :space => nil, :phase => 0 }
52
- @cap_style = previous_state ? previous_state.cap_style : :butt
53
- @join_style = previous_state ? previous_state.join_style : :miter
54
- @line_width = previous_state ? previous_state.line_width : 1
55
- end
56
-
57
- def dash_setting
58
- "[#{@dash[:dash]} #{@dash[:space]}] #{@dash[:phase]} d"
59
- end
60
- end
61
-
62
- module Core
63
- class Page
64
- module GraphicsState
65
-
66
- def graphic_state
67
- stack.current_state
68
- end
69
-
70
- end
71
- end
72
- end
73
-
74
11
  class Document
75
- module GraphicsState
12
+ module GraphicsState # @private
76
13
 
77
14
  # Pushes the current graphics state on to the graphics state stack so we
78
15
  # can restore it when finished with a change we want to isolate (such as
@@ -93,15 +30,15 @@ module Prawn
93
30
  # text "rotated text"
94
31
  # end
95
32
  #
96
-
33
+
97
34
  def open_graphics_state
98
35
  add_content "q"
99
36
  end
100
-
37
+
101
38
  def close_graphics_state
102
39
  add_content "Q"
103
40
  end
104
-
41
+
105
42
  def save_graphics_state(graphic_state = nil)
106
43
  graphic_stack.save_graphic_state(graphic_state)
107
44
  open_graphics_state
@@ -115,22 +52,22 @@ module Prawn
115
52
  # restores the state to those values
116
53
  def restore_graphics_state
117
54
  if graphic_stack.empty?
118
- raise Prawn::Errors::EmptyGraphicStateStack,
119
- "\n You have reached the end of the graphic state stack"
55
+ raise PDF::Core::Errors::EmptyGraphicStateStack,
56
+ "\n You have reached the end of the graphic state stack"
120
57
  end
121
- close_graphics_state
58
+ close_graphics_state
122
59
  graphic_stack.restore_graphic_state
123
60
  end
124
-
61
+
125
62
  def graphic_stack
126
63
  state.page.stack
127
64
  end
128
-
65
+
129
66
  def graphic_state
130
67
  save_graphics_state unless graphic_stack.current_state
131
- graphic_stack.current_state
68
+ graphic_stack.current_state
132
69
  end
133
-
70
+
134
71
  end
135
72
  end
136
73
  end
@@ -7,26 +7,26 @@
7
7
  # This is free software. Please see the LICENSE and COPYING files for details.
8
8
 
9
9
  module Prawn
10
- class Document
11
-
10
+ class Document
11
+
12
12
  # This module exposes a few low-level PDF features for those who want
13
13
  # to extend Prawn's core functionality. If you are not comfortable with
14
14
  # low level PDF functionality as defined by Adobe's specification, chances
15
- # are you won't need anything you find here.
15
+ # are you won't need anything you find here.
16
16
  #
17
- module Internals
18
-
17
+ # @private
18
+ module Internals
19
19
  # Creates a new Prawn::Reference and adds it to the Document's object
20
- # list. The +data+ argument is anything that Prawn::PdfObject() can convert.
20
+ # list. The +data+ argument is anything that Prawn::PdfObject() can convert.
21
+ #
22
+ # Returns the identifier which points to the reference in the ObjectStore
21
23
  #
22
- # Returns the identifier which points to the reference in the ObjectStore
23
- #
24
24
  def ref(data)
25
25
  ref!(data).identifier
26
- end
26
+ end
27
27
 
28
28
  # Like ref, but returns the actual reference instead of its identifier.
29
- #
29
+ #
30
30
  # While you can use this to build up nested references within the object
31
31
  # tree, it is recommended to persist only identifiers, and them provide
32
32
  # helper methods to look up the actual references in the ObjectStore
@@ -42,21 +42,21 @@ module Prawn
42
42
  # of if it's hidden behind a Prawn::Reference, wrap it in deref().
43
43
  #
44
44
  def deref(obj)
45
- obj.is_a?(Prawn::Core::Reference) ? obj.data : obj
45
+ obj.is_a?(PDF::Core::Reference) ? obj.data : obj
46
46
  end
47
47
 
48
48
  # Appends a raw string to the current page content.
49
- #
50
- # # Raw line drawing example:
49
+ #
50
+ # # Raw line drawing example:
51
51
  # x1,y1,x2,y2 = 100,500,300,550
52
- # pdf.add_content("%.3f %.3f m" % [ x1, y1 ]) # move
52
+ # pdf.add_content("%.3f %.3f m" % [ x1, y1 ]) # move
53
53
  # pdf.add_content("%.3f %.3f l" % [ x2, y2 ]) # draw path
54
- # pdf.add_content("S") # stroke
54
+ # pdf.add_content("S") # stroke
55
55
  #
56
56
  def add_content(str)
57
57
  save_graphics_state if graphic_state.nil?
58
58
  state.page.content << str << "\n"
59
- end
59
+ end
60
60
 
61
61
  # The Name dictionary (PDF spec 3.6.3) for this document. It is
62
62
  # lazily initialized, so that documents that do not need a name
@@ -67,7 +67,7 @@ module Prawn
67
67
  end
68
68
 
69
69
  # Returns true if the Names dictionary is in use for this document.
70
- #
70
+ #
71
71
  def names?
72
72
  state.store.root.data[:Names]
73
73
  end
@@ -87,8 +87,8 @@ module Prawn
87
87
  state.on_page_create_callback = nil
88
88
  end
89
89
  end
90
-
91
- private
90
+
91
+ private
92
92
 
93
93
  # adds a new, empty content stream to each page. Used in templating so
94
94
  # that imported content streams can be left pristine
@@ -100,6 +100,7 @@ module Prawn
100
100
  apply_margin_options(options)
101
101
  generate_margin_box
102
102
  use_graphic_settings(options[:template])
103
+ forget_text_rendering_mode!
103
104
  end
104
105
  end
105
106
 
@@ -156,18 +157,18 @@ module Prawn
156
157
  # Write out the PDF Trailer, as per spec 3.4.4
157
158
  #
158
159
  def render_trailer(output)
159
- trailer_hash = {:Size => state.store.size + 1,
160
+ trailer_hash = {:Size => state.store.size + 1,
160
161
  :Root => state.store.root,
161
162
  :Info => state.store.info}
162
163
  trailer_hash.merge!(state.trailer) if state.trailer
163
164
 
164
165
  output << "trailer\n"
165
- output << Prawn::Core::PdfObject(trailer_hash) << "\n"
166
- output << "startxref\n"
166
+ output << PDF::Core::PdfObject(trailer_hash) << "\n"
167
+ output << "startxref\n"
167
168
  output << @xref_offset << "\n"
168
169
  output << "%%EOF" << "\n"
169
170
  end
170
-
171
+
171
172
  end
172
173
  end
173
174
  end
@@ -8,8 +8,10 @@
8
8
 
9
9
  module Prawn
10
10
  class Document
11
- # A span is a special purpose bounding box that allows a column of
12
- # elements to be positioned relative to the margin_box.
11
+ # @group Stable API
12
+
13
+ # A span is a special purpose bounding box that allows a column of
14
+ # elements to be positioned relative to the margin_box.
13
15
  #
14
16
  # Arguments:
15
17
  # +width+:: The width of the column in PDF points
@@ -17,23 +19,23 @@ module Prawn
17
19
  # Options:
18
20
  # <tt>:position</tt>:: One of :left, :center, :right or an x offset
19
21
  #
20
- # This method is typically used for flowing a column of text from one
22
+ # This method is typically used for flowing a column of text from one
21
23
  # page to the next.
22
24
  #
23
25
  # span(350, :position => :center) do
24
26
  # text "Here's some centered text in a 350 point column. " * 100
25
27
  # end
26
- #
28
+ #
27
29
  def span(width, options={})
28
30
  Prawn.verify_options [:position], options
29
- original_position = self.y
30
-
31
+ original_position = self.y
32
+
31
33
  # FIXME: Any way to move this upstream?
32
34
  left_boundary = case(options[:position] || :left)
33
35
  when :left
34
36
  margin_box.absolute_left
35
37
  when :center
36
- margin_box.absolute_left + margin_box.width / 2.0 - width /2.0
38
+ margin_box.absolute_left + margin_box.width / 2.0 - width / 2.0
37
39
  when :right
38
40
  margin_box.absolute_right - width
39
41
  when Numeric
@@ -41,15 +43,15 @@ module Prawn
41
43
  else
42
44
  raise ArgumentError, "Invalid option for :position"
43
45
  end
44
-
46
+
45
47
  # we need to bust out of whatever nested bounding boxes we're in.
46
48
  canvas do
47
- bounding_box([left_boundary,
49
+ bounding_box([left_boundary,
48
50
  margin_box.absolute_top], :width => width) do
49
51
  self.y = original_position
50
52
  yield
51
53
  end
52
- end
54
+ end
53
55
  end
54
56
  end
55
57
  end