prawn 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -2
  3. data/lib/prawn.rb +5 -3
  4. data/lib/prawn/document.rb +7 -7
  5. data/lib/prawn/document/bounding_box.rb +1 -1
  6. data/lib/prawn/document/column_box.rb +3 -3
  7. data/lib/prawn/document/internals.rb +1 -1
  8. data/lib/prawn/font.rb +24 -8
  9. data/lib/prawn/font/afm.rb +4 -4
  10. data/lib/prawn/font_metric_cache.rb +1 -1
  11. data/lib/prawn/grid.rb +3 -1
  12. data/lib/prawn/image_handler.rb +3 -1
  13. data/lib/prawn/images/jpg.rb +1 -1
  14. data/lib/prawn/measurement_extensions.rb +1 -1
  15. data/lib/prawn/outline.rb +3 -1
  16. data/lib/prawn/security.rb +1 -1
  17. data/lib/prawn/security/arcfour.rb +4 -2
  18. data/lib/prawn/table.rb +14 -2
  19. data/lib/prawn/table/cell.rb +1 -1
  20. data/lib/prawn/table/cells.rb +1 -50
  21. data/lib/prawn/table/column_width_calculator.rb +131 -10
  22. data/lib/prawn/text.rb +1 -1
  23. data/lib/prawn/text/formatted.rb +2 -0
  24. data/lib/prawn/text/formatted/arranger.rb +1 -1
  25. data/lib/prawn/text/formatted/box.rb +5 -5
  26. data/lib/prawn/text/formatted/line_wrap.rb +1 -1
  27. data/lib/prawn/text/formatted/wrap.rb +2 -0
  28. data/lib/prawn/utilities.rb +3 -3
  29. data/manual/absolute_position.pdf +0 -0
  30. data/manual/basic_concepts/adding_pages.rb +3 -3
  31. data/manual/basic_concepts/basic_concepts.rb +6 -6
  32. data/manual/basic_concepts/cursor.rb +5 -5
  33. data/manual/basic_concepts/measurement.rb +2 -2
  34. data/manual/basic_concepts/origin.rb +3 -3
  35. data/manual/basic_concepts/other_cursor_helpers.rb +6 -6
  36. data/manual/bounding_box/bounding_box.rb +6 -6
  37. data/manual/bounding_box/bounds.rb +6 -6
  38. data/manual/bounding_box/canvas.rb +2 -2
  39. data/manual/bounding_box/creation.rb +3 -3
  40. data/manual/bounding_box/indentation.rb +9 -9
  41. data/manual/bounding_box/nesting.rb +8 -8
  42. data/manual/bounding_box/russian_boxes.rb +1 -1
  43. data/manual/bounding_box/stretchy.rb +8 -8
  44. data/manual/{manual/manual.rb → contents.rb} +6 -9
  45. data/manual/{manual/cover.rb → cover.rb} +6 -6
  46. data/manual/document_and_page_options/background.rb +2 -2
  47. data/manual/document_and_page_options/document_and_page_options.rb +4 -4
  48. data/manual/document_and_page_options/metadata.rb +2 -2
  49. data/manual/document_and_page_options/page_margins.rb +2 -2
  50. data/manual/document_and_page_options/page_size.rb +3 -3
  51. data/manual/example_helper.rb +5 -409
  52. data/manual/graphics/circle_and_ellipse.rb +4 -4
  53. data/manual/graphics/color.rb +4 -4
  54. data/manual/graphics/common_lines.rb +5 -5
  55. data/manual/graphics/fill_and_stroke.rb +5 -5
  56. data/manual/graphics/fill_rules.rb +1 -1
  57. data/manual/graphics/gradients.rb +1 -1
  58. data/manual/graphics/graphics.rb +8 -8
  59. data/manual/graphics/helper.rb +1 -1
  60. data/manual/graphics/line_width.rb +5 -5
  61. data/manual/graphics/lines_and_curves.rb +5 -5
  62. data/manual/graphics/polygon.rb +4 -4
  63. data/manual/graphics/rectangle.rb +3 -3
  64. data/manual/graphics/rotate.rb +5 -5
  65. data/manual/graphics/scale.rb +5 -5
  66. data/manual/graphics/soft_masks.rb +1 -1
  67. data/manual/graphics/stroke_cap.rb +3 -3
  68. data/manual/graphics/stroke_dash.rb +1 -1
  69. data/manual/graphics/stroke_join.rb +4 -4
  70. data/manual/graphics/translate.rb +5 -5
  71. data/manual/graphics/transparency.rb +5 -5
  72. data/manual/{manual/how_to_read_this_manual.rb → how_to_read_this_manual.rb} +16 -17
  73. data/manual/images/absolute_position.rb +3 -3
  74. data/manual/images/fit.rb +2 -2
  75. data/manual/images/horizontal.rb +3 -3
  76. data/manual/images/images.rb +7 -7
  77. data/manual/images/plain_image.rb +1 -1
  78. data/manual/images/scale.rb +3 -3
  79. data/manual/images/vertical.rb +3 -3
  80. data/manual/images/width_and_height.rb +3 -3
  81. data/manual/layout/boxes.rb +4 -4
  82. data/manual/layout/content.rb +3 -3
  83. data/manual/layout/layout.rb +5 -5
  84. data/manual/layout/simple_grid.rb +2 -2
  85. data/manual/outline/add_subsection_to.rb +7 -7
  86. data/manual/outline/insert_section_after.rb +5 -5
  87. data/manual/outline/outline.rb +6 -6
  88. data/manual/outline/sections_and_pages.rb +9 -9
  89. data/manual/repeatable_content/page_numbering.rb +3 -3
  90. data/manual/repeatable_content/repeatable_content.rb +5 -5
  91. data/manual/repeatable_content/repeater.rb +4 -4
  92. data/manual/repeatable_content/stamp.rb +4 -4
  93. data/manual/security/encryption.rb +2 -2
  94. data/manual/security/permissions.rb +2 -2
  95. data/manual/security/security.rb +5 -5
  96. data/manual/table/basic_block.rb +5 -5
  97. data/manual/table/before_rendering_page.rb +1 -1
  98. data/manual/table/cell_border_lines.rb +4 -4
  99. data/manual/table/cell_borders_and_bg.rb +4 -4
  100. data/manual/table/cell_dimensions.rb +3 -3
  101. data/manual/table/cell_text.rb +6 -6
  102. data/manual/table/column_widths.rb +4 -4
  103. data/manual/table/content_and_subtables.rb +5 -5
  104. data/manual/table/creation.rb +2 -2
  105. data/manual/table/filtering.rb +6 -6
  106. data/manual/table/flow_and_header.rb +2 -2
  107. data/manual/table/image_cells.rb +1 -1
  108. data/manual/table/position.rb +1 -1
  109. data/manual/table/row_colors.rb +3 -3
  110. data/manual/table/span.rb +1 -1
  111. data/manual/table/style.rb +3 -3
  112. data/manual/table/table.rb +7 -7
  113. data/manual/table/width.rb +3 -3
  114. data/manual/text/alignment.rb +1 -1
  115. data/manual/text/color.rb +1 -1
  116. data/manual/text/column_box.rb +1 -1
  117. data/manual/text/fallback_fonts.rb +3 -3
  118. data/manual/text/font.rb +7 -7
  119. data/manual/text/font_size.rb +9 -9
  120. data/manual/text/font_style.rb +3 -3
  121. data/manual/text/formatted_callbacks.rb +3 -3
  122. data/manual/text/formatted_text.rb +3 -3
  123. data/manual/text/free_flowing_text.rb +6 -6
  124. data/manual/text/inline.rb +5 -5
  125. data/manual/text/kerning_and_character_spacing.rb +7 -7
  126. data/manual/text/leading.rb +4 -4
  127. data/manual/text/line_wrapping.rb +4 -4
  128. data/manual/text/paragraph_indentation.rb +3 -3
  129. data/manual/text/positioned_text.rb +3 -3
  130. data/manual/text/registering_families.rb +6 -6
  131. data/manual/text/rendering_and_color.rb +2 -2
  132. data/manual/text/right_to_left_text.rb +2 -2
  133. data/manual/text/rotation.rb +4 -4
  134. data/manual/text/single_usage.rb +3 -3
  135. data/manual/text/text.rb +9 -9
  136. data/manual/text/text_box_excess.rb +2 -2
  137. data/manual/text/text_box_extensions.rb +3 -3
  138. data/manual/text/text_box_overflow.rb +4 -4
  139. data/manual/text/utf8.rb +5 -5
  140. data/manual/text/win_ansi_charset.rb +1 -1
  141. data/prawn.gemspec +5 -3
  142. data/spec/acceptance/png.rb +5 -3
  143. data/spec/cell_spec.rb +1 -0
  144. data/spec/column_box_spec.rb +1 -1
  145. data/spec/extensions/encoding_helpers.rb +2 -0
  146. data/spec/extensions/mocha.rb +2 -0
  147. data/spec/font_spec.rb +15 -0
  148. data/spec/measurement_units_spec.rb +2 -0
  149. data/spec/repeater_spec.rb +2 -0
  150. data/spec/soft_mask_spec.rb +2 -0
  151. data/spec/stamp_spec.rb +2 -0
  152. data/spec/table_spec.rb +103 -10
  153. data/spec/text_spec.rb +1 -1
  154. data/spec/transparency_spec.rb +2 -0
  155. metadata +42 -18
  156. data/lib/prawn/layout.rb +0 -17
  157. data/manual/example_file.rb +0 -111
  158. data/manual/example_package.rb +0 -53
  159. data/manual/example_section.rb +0 -46
  160. data/manual/syntax_highlight.rb +0 -52
@@ -11,12 +11,12 @@ require File.expand_path(File.join(File.dirname(__FILE__),
11
11
  %w[.. example_helper]))
12
12
 
13
13
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
14
- Prawn::Example.generate(filename) do
14
+ Prawn::ManualBuilder::Example.generate(filename) do
15
15
  stroke_axis
16
-
16
+
17
17
  stroke_circle [100, 300], 100
18
-
18
+
19
19
  fill_ellipse [200, 100], 100, 50
20
-
20
+
21
21
  fill_ellipse [400, 100], 50
22
22
  end
@@ -7,18 +7,18 @@ require File.expand_path(File.join(File.dirname(__FILE__),
7
7
  %w[.. example_helper]))
8
8
 
9
9
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
10
- Prawn::Example.generate(filename) do
10
+ Prawn::ManualBuilder::Example.generate(filename) do
11
11
  stroke_axis
12
-
12
+
13
13
  # Fill with Yellow using RGB
14
14
  fill_color "FFFFCC"
15
15
  fill_polygon [50, 150], [150, 200], [250, 150],
16
16
  [250, 50], [150, 0], [50, 50]
17
-
17
+
18
18
  # Stroke with Purple using CMYK
19
19
  stroke_color 50, 100, 0, 0
20
20
  stroke_rectangle [300, 300], 200, 100
21
-
21
+
22
22
  # Both together
23
23
  fill_and_stroke_circle [400, 100], 50
24
24
  end
@@ -13,18 +13,18 @@ require File.expand_path(File.join(File.dirname(__FILE__),
13
13
  %w[.. example_helper]))
14
14
 
15
15
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
16
- Prawn::Example.generate(filename) do
16
+ Prawn::ManualBuilder::Example.generate(filename) do
17
17
  stroke_axis
18
18
 
19
19
  stroke_color "ff0000"
20
-
20
+
21
21
  stroke do
22
22
  # just lower the current y position
23
- move_down 50
23
+ move_down 50
24
24
  horizontal_rule
25
-
25
+
26
26
  vertical_line 100, 300, :at => 50
27
-
27
+
28
28
  horizontal_line 200, 500, :at => 150
29
29
  end
30
30
  end
@@ -22,20 +22,20 @@ require File.expand_path(File.join(File.dirname(__FILE__),
22
22
  %w[.. example_helper]))
23
23
 
24
24
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
25
- Prawn::Example.generate(filename) do
25
+ Prawn::ManualBuilder::Example.generate(filename) do
26
26
  stroke_axis
27
-
27
+
28
28
  # No block
29
29
  line [0, 200], [100, 150]
30
30
  stroke
31
-
31
+
32
32
  rectangle [0, 100], 100, 100
33
33
  fill
34
-
34
+
35
35
  # With block
36
36
  stroke { line [200, 200], [300, 150] }
37
37
  fill { rectangle [200, 100], 100, 100 }
38
-
38
+
39
39
  # Method hook
40
40
  stroke_line [400, 200], [500, 150]
41
41
  fill_rectangle [400, 100], 100, 100
@@ -20,7 +20,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
20
20
  %w[.. example_helper]))
21
21
 
22
22
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
23
- Prawn::Example.generate(filename) do
23
+ Prawn::ManualBuilder::Example.generate(filename) do
24
24
  pentagram = [[181, 95], [0, 36], [111, 190], [111, 0], [0, 154]]
25
25
 
26
26
  stroke_color 'ff0000'
@@ -8,7 +8,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
8
8
  %w[.. example_helper]))
9
9
 
10
10
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
11
- Prawn::Example.generate(filename) do
11
+ Prawn::ManualBuilder::Example.generate(filename) do
12
12
  stroke_axis
13
13
  self.line_width = 10
14
14
 
@@ -5,15 +5,15 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),
6
6
  %w[.. example_helper]))
7
7
 
8
- Prawn::Example.generate("graphics.pdf", :page_size => "FOLIO") do
9
-
8
+ Prawn::ManualBuilder::Example.generate("graphics.pdf", :page_size => "FOLIO") do
9
+
10
10
  package "graphics" do |p|
11
-
11
+
12
12
  p.section "Basics" do |s|
13
13
  s.example "helper"
14
14
  s.example "fill_and_stroke"
15
15
  end
16
-
16
+
17
17
  p.section "Shapes" do |s|
18
18
  s.example "lines_and_curves"
19
19
  s.example "common_lines"
@@ -21,7 +21,7 @@ Prawn::Example.generate("graphics.pdf", :page_size => "FOLIO") do
21
21
  s.example "polygon"
22
22
  s.example "circle_and_ellipse"
23
23
  end
24
-
24
+
25
25
  p.section "Fill and Stroke settings" do |s|
26
26
  s.example "line_width"
27
27
  s.example "stroke_cap"
@@ -33,13 +33,13 @@ Prawn::Example.generate("graphics.pdf", :page_size => "FOLIO") do
33
33
  s.example "soft_masks"
34
34
  s.example "fill_rules"
35
35
  end
36
-
36
+
37
37
  p.section "Transformations" do |s|
38
38
  s.example "rotate"
39
39
  s.example "translate"
40
40
  s.example "scale"
41
41
  end
42
-
42
+
43
43
  p.intro do
44
44
  prose("Here we show all the drawing methods provided by Prawn. Use them to draw the most beautiful imaginable things.
45
45
 
@@ -53,6 +53,6 @@ Prawn::Example.generate("graphics.pdf", :page_size => "FOLIO") do
53
53
  "How to apply transformations to your drawing space"
54
54
  )
55
55
  end
56
-
56
+
57
57
  end
58
58
  end
@@ -15,7 +15,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
15
15
  %w[.. example_helper]))
16
16
 
17
17
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
18
- Prawn::Example.generate(filename) do
18
+ Prawn::ManualBuilder::Example.generate(filename) do
19
19
  stroke_axis
20
20
  stroke_axis(:at => [70, 70], :height => 200, :step_length => 50,
21
21
  :negative_axes_length => 5, :color => '0000FF')
@@ -12,24 +12,24 @@ require File.expand_path(File.join(File.dirname(__FILE__),
12
12
  %w[.. example_helper]))
13
13
 
14
14
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
15
- Prawn::Example.generate(filename) do
15
+ Prawn::ManualBuilder::Example.generate(filename) do
16
16
  stroke_axis
17
-
17
+
18
18
  y = 250
19
-
19
+
20
20
  3.times do |i|
21
21
  case i
22
22
  when 0 then line_width = 10 # This call will have no effect
23
23
  when 1 then self.line_width = 10
24
24
  when 2 then self.line_width = 25
25
25
  end
26
-
26
+
27
27
  stroke do
28
28
  horizontal_line 50, 150, :at => y
29
29
  rectangle [275, y + 25], 50, 50
30
30
  circle [500, y], 25
31
31
  end
32
-
32
+
33
33
  y -= 100
34
34
  end
35
35
  end
@@ -19,20 +19,20 @@ require File.expand_path(File.join(File.dirname(__FILE__),
19
19
  %w[.. example_helper]))
20
20
 
21
21
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
22
- Prawn::Example.generate(filename) do
22
+ Prawn::ManualBuilder::Example.generate(filename) do
23
23
  stroke_axis
24
-
24
+
25
25
  # line_to and curve_to
26
26
  stroke do
27
27
  move_to 0, 0
28
-
28
+
29
29
  line_to 100, 100
30
30
  line_to 0, 100
31
-
31
+
32
32
  curve_to [150, 250], :bounds => [[20, 200], [120, 200]]
33
33
  curve_to [200, 0], :bounds => [[150, 200], [450, 10]]
34
34
  end
35
-
35
+
36
36
  # line and curve
37
37
  stroke do
38
38
  line [300,200], [400,50]
@@ -11,19 +11,19 @@ require File.expand_path(File.join(File.dirname(__FILE__),
11
11
  %w[.. example_helper]))
12
12
 
13
13
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
14
- Prawn::Example.generate(filename) do
14
+ Prawn::ManualBuilder::Example.generate(filename) do
15
15
  stroke_axis
16
16
 
17
17
  # Triangle
18
18
  stroke_polygon [50, 200], [50, 300], [150, 300]
19
-
19
+
20
20
  # Hexagon
21
21
  fill_polygon [50, 150], [150, 200], [250, 150],
22
22
  [250, 50], [150, 0], [50, 50]
23
-
23
+
24
24
  # Pentagram
25
25
  pentagon_points = [500, 100], [430, 5], [319, 41], [319, 159], [430, 195]
26
26
  pentagram_points = [0, 2, 4, 1, 3].map{ |i| pentagon_points[i] }
27
-
27
+
28
28
  stroke_rounded_polygon(20, *pentagram_points)
29
29
  end
@@ -10,12 +10,12 @@ require File.expand_path(File.join(File.dirname(__FILE__),
10
10
  %w[.. example_helper]))
11
11
 
12
12
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
13
- Prawn::Example.generate(filename) do
13
+ Prawn::ManualBuilder::Example.generate(filename) do
14
14
  stroke_axis
15
-
15
+
16
16
  stroke do
17
17
  rectangle [100, 300], 100, 200
18
-
18
+
19
19
  rounded_rectangle [300, 300], 100, 200, 20
20
20
  end
21
21
  end
@@ -12,15 +12,15 @@ require File.expand_path(File.join(File.dirname(__FILE__),
12
12
  %w[.. example_helper]))
13
13
 
14
14
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
15
- Prawn::Example.generate(filename) do
15
+ Prawn::ManualBuilder::Example.generate(filename) do
16
16
  stroke_axis
17
-
17
+
18
18
  fill_circle [250, 200], 2
19
-
19
+
20
20
  12.times do |i|
21
-
21
+
22
22
  rotate(i * 30, :origin => [250, 200]) do
23
-
23
+
24
24
  stroke_rectangle [350, 225], 100, 50
25
25
  draw_text "Rotated #{i * 30}°", :size => 10, :at => [360, 205]
26
26
  end
@@ -10,18 +10,18 @@ require File.expand_path(File.join(File.dirname(__FILE__),
10
10
  %w[.. example_helper]))
11
11
 
12
12
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
13
- Prawn::Example.generate(filename) do
13
+ Prawn::ManualBuilder::Example.generate(filename) do
14
14
  stroke_axis
15
-
15
+
16
16
  width = 100
17
17
  height = 50
18
-
18
+
19
19
  x = 50
20
20
  y = 200
21
21
 
22
22
  stroke_rectangle [x, y], width, height
23
23
  text_box "reference rectangle", :at => [x + 10, y - 10], :width => width - 20
24
-
24
+
25
25
  scale(2, :origin => [x, y]) do
26
26
  stroke_rectangle [x, y], width, height
27
27
  text_box "rectangle scaled from upper-left corner",
@@ -32,7 +32,7 @@ Prawn::Example.generate(filename) do
32
32
 
33
33
  stroke_rectangle [x, y], width, height
34
34
  text_box "reference rectangle", :at => [x + 10, y - 10], :width => width - 20
35
-
35
+
36
36
  scale(2, :origin => [x + width / 2, y - height / 2]) do
37
37
  stroke_rectangle [x, y], width, height
38
38
  text_box "rectangle scaled from center",
@@ -15,7 +15,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
15
15
  %w[.. example_helper]))
16
16
 
17
17
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
18
- Prawn::Example.generate(filename) do
18
+ Prawn::ManualBuilder::Example.generate(filename) do
19
19
  save_graphics_state do
20
20
  soft_mask do
21
21
  0.upto 15 do |i|
@@ -16,14 +16,14 @@ require File.expand_path(File.join(File.dirname(__FILE__),
16
16
  %w[.. example_helper]))
17
17
 
18
18
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
19
- Prawn::Example.generate(filename) do
19
+ Prawn::ManualBuilder::Example.generate(filename) do
20
20
  stroke_axis
21
-
21
+
22
22
  self.line_width = 25
23
23
 
24
24
  [:butt, :round, :projecting_square].each_with_index do |cap, i|
25
25
  self.cap_style = cap
26
-
26
+
27
27
  y = 250 - i*100
28
28
  stroke_horizontal_line 100, 300, :at => y
29
29
  stroke_circle [400, y], 15
@@ -17,7 +17,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
17
17
  %w[.. example_helper]))
18
18
 
19
19
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
20
- Prawn::Example.generate(filename) do
20
+ Prawn::ManualBuilder::Example.generate(filename) do
21
21
  stroke_axis
22
22
 
23
23
  dash([1, 2, 3, 2, 1, 5], :phase => 6)
@@ -11,14 +11,14 @@ require File.expand_path(File.join(File.dirname(__FILE__),
11
11
  %w[.. example_helper]))
12
12
 
13
13
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
14
- Prawn::Example.generate(filename) do
14
+ Prawn::ManualBuilder::Example.generate(filename) do
15
15
  stroke_axis
16
-
16
+
17
17
  self.line_width = 25
18
-
18
+
19
19
  [:miter, :round, :bevel].each_with_index do |style, i|
20
20
  self.join_style = style
21
-
21
+
22
22
  y = 200 - i*100
23
23
  stroke do
24
24
  move_to(100, y)
@@ -7,20 +7,20 @@ require File.expand_path(File.join(File.dirname(__FILE__),
7
7
  %w[.. example_helper]))
8
8
 
9
9
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
10
- Prawn::Example.generate(filename) do
10
+ Prawn::ManualBuilder::Example.generate(filename) do
11
11
  stroke_axis
12
-
12
+
13
13
  1.upto(3) do |i|
14
-
14
+
15
15
  x = i * 50
16
16
  y = i * 100
17
17
  translate(x, y) do
18
-
18
+
19
19
  # Draw a point on the new origin
20
20
  fill_circle [0, 0], 2
21
21
  draw_text "New origin after translation to [#{x}, #{y}]",
22
22
  :at => [5, -2], :size => 8
23
-
23
+
24
24
  stroke_rectangle [100, 75], 100, 50
25
25
  text_box "Top left corner at [100,75]",
26
26
  :at => [110, 65], :width => 80, :size => 8
@@ -12,24 +12,24 @@ require File.expand_path(File.join(File.dirname(__FILE__),
12
12
  %w[.. example_helper]))
13
13
 
14
14
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
15
- Prawn::Example.generate(filename) do
15
+ Prawn::ManualBuilder::Example.generate(filename) do
16
16
  stroke_axis
17
17
 
18
18
  self.line_width = 5
19
19
  fill_color "ff0000"
20
20
  fill_rectangle [0, 100], 500, 100
21
-
21
+
22
22
  fill_color "000000"
23
23
  stroke_color "ffffff"
24
-
24
+
25
25
  base_x = 100
26
26
  [[0.5, 1], 0.5, [1, 0.5]].each do |args|
27
-
27
+
28
28
  transparent(*args) do
29
29
  fill_circle [base_x, 100], 50
30
30
  stroke_rectangle [base_x - 20, 100], 40, 80
31
31
  end
32
-
32
+
33
33
  base_x += 150
34
34
  end
35
35
  end
@@ -1,40 +1,39 @@
1
1
  # encoding: utf-8
2
2
  #
3
- # Prawn manual how to read this manual page.
4
- #
5
- require File.expand_path(File.join(File.dirname(__FILE__),
6
- %w[.. example_helper]))
3
+ # Prawn manual how to read this manual page.
4
+
5
+ require_relative "example_helper"
7
6
 
8
7
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
9
- Prawn::Example.generate(filename) do
8
+ Prawn::ManualBuilder::Example.generate(filename) do
10
9
  header("How to read this manual")
11
-
10
+
12
11
  prose <<-END_TEXT
13
12
  This manual is a collection of examples categorized by theme and organized from the least to the most complex. While it covers most of the common use cases it is not a comprehensive guide.
14
-
13
+
15
14
  The best way to read it depends on your previous knowledge of Prawn and what you need to accomplish.
16
-
15
+
17
16
  If you are beginning with Prawn the first chapter will teach you the most basic concepts and how to create pdf documents. For an overview of the other features each chapter beyond the first either has a Basics section (which offer enough insight on the feature without showing all the advanced stuff you might never use) or is simple enough with only a few examples.
18
-
17
+
19
18
  Once you understand the basics you might want to come back to this manual looking for examples that accomplish tasks you need.
20
-
19
+
21
20
  Advanced users are encouraged to go beyond this manual and read the source code directly if any doubt is not directly covered on this manual.
22
21
  END_TEXT
23
-
24
- move_down(BOX_MARGIN)
22
+
23
+ move_down(Prawn::ManualBuilder::Example::BOX_MARGIN)
25
24
  header("Reading the examples")
26
-
25
+
27
26
  prose <<-END_TEXT
28
27
  The title of each example is the relative path from the Prawn source manual/ folder.
29
-
28
+
30
29
  The first body of text is the introductory text for the example. Generaly it is a short description of the features illustrated by the example.
31
-
30
+
32
31
  Next comes the example source code block in fixed width font.
33
-
32
+
34
33
  Most of the example snippets illustrate features that alter the page in place. The effect of these snippets is shown right below a dashed line. If it doesn't make sense to evaluate the snippet inline, a box with the link for the example file is shown instead.
35
34
 
36
35
  Note that the <code>stroke_axis</code> method, used occasionally in the manual, is not part of standard Prawn and is used for demonstrative purposes. It is defined in this file:
37
-
36
+
38
37
  https://github.com/prawnpdf/prawn/blob/master/manual/example_helper.rb
39
38
  END_TEXT
40
39