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
@@ -9,11 +9,11 @@ require File.expand_path(File.join(File.dirname(__FILE__),
9
9
  %w[.. example_helper]))
10
10
 
11
11
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
12
- Prawn::Example.generate(filename) do
12
+ Prawn::ManualBuilder::Example.generate(filename) do
13
13
  text "Normal width:"
14
14
  table [%w[A B C]]
15
15
  move_down 20
16
-
16
+
17
17
  text "Fixed width:"
18
18
  table([%w[A B C]], :width => 300)
19
19
  move_down 20
@@ -21,7 +21,7 @@ Prawn::Example.generate(filename) do
21
21
  text "Normal width:"
22
22
  table([["A", "Blah " * 20, "C"]])
23
23
  move_down 20
24
-
24
+
25
25
  text "Fixed width:"
26
26
  table([["A", "Blah " * 20, "C"]], :width => 300)
27
27
  end
@@ -16,7 +16,7 @@ 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
  text "This text should be left aligned"
21
21
  text "This text should be centered", :align => :center
22
22
  text "This text should be right aligned", :align => :right
@@ -7,7 +7,7 @@ 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
  text "Default color is black"
12
12
  move_down 25
13
13
 
@@ -9,7 +9,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
9
9
  %w[.. example_helper]))
10
10
 
11
11
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
12
- Prawn::Example.generate(filename) do
12
+ Prawn::ManualBuilder::Example.generate(filename) do
13
13
  text "The Prince", :align => :center, :size => 18
14
14
  text "Niccolò Machiavelli", :align => :center, :size => 14
15
15
  move_down 12
@@ -8,17 +8,17 @@ 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
  file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
13
13
  font_families["Kai"] = {
14
14
  :normal => { :file => file, :font => "Kai" }
15
15
  }
16
-
16
+
17
17
  file = "#{Prawn::DATADIR}/fonts/Panic+Sans.dfont"
18
18
  font_families["Panic Sans"] = {
19
19
  :normal => { :file => file, :font => "PanicSans" },
20
20
  }
21
-
21
+
22
22
  font("Panic Sans") do
23
23
  text("When fallback fonts are included, each glyph will be rendered " +
24
24
  "using the first font that includes the glyph, starting with the " +
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # The <code>font</code> method can be used in three different ways.
4
4
  #
5
5
  # If we don't pass it any arguments it will return the current font being used
@@ -17,24 +17,24 @@ 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
  text "Let's see which font we are using: #{font.inspect}"
22
-
22
+
23
23
  move_down 20
24
24
  font "Times-Roman"
25
25
  text "Written in Times."
26
-
26
+
27
27
  move_down 20
28
28
  font("Courier") do
29
29
  text "Written in Courier because we are inside the block."
30
30
  end
31
-
31
+
32
32
  move_down 20
33
33
  text "Written in Times again as we left the previous block."
34
-
34
+
35
35
  move_down 20
36
36
  text "Let's see which font we are using again: #{font.inspect}"
37
-
37
+
38
38
  move_down 20
39
39
  font "Helvetica"
40
40
  text "Back to normal."
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # The <code>font_size</code> method works just like the <code>font</code>
4
4
  # method.
5
5
  #
@@ -15,30 +15,30 @@ 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
  text "Let's see which is the current font_size: #{font_size.inspect}"
20
-
20
+
21
21
  move_down 10
22
22
  font_size 16
23
23
  text "Yeah, something bigger!"
24
-
24
+
25
25
  move_down 10
26
26
  font_size(25) { text "Even bigger!" }
27
-
27
+
28
28
  move_down 10
29
29
  text "Back to 16 again."
30
-
30
+
31
31
  move_down 10
32
32
  text "Single line on 20 using the :size option.", :size => 20
33
-
33
+
34
34
  move_down 10
35
35
  text "Back to 16 once more."
36
-
36
+
37
37
  move_down 10
38
38
  font("Courier", :size => 10) do
39
39
  text "Yeah, using Courier 10 courtesy of the font method."
40
40
  end
41
-
41
+
42
42
  move_down 10
43
43
  font("Helvetica", :size => 12)
44
44
  text "Back to normal"
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # Most font families come with some styles other than normal. Most common are
4
4
  # <code>bold</code>, <code>italic</code> and <code>bold_italic</code>.
5
5
  #
@@ -11,10 +11,10 @@ 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
  ["Courier", "Helvetica", "Times-Roman"].each do |example_font|
16
16
  move_down 20
17
-
17
+
18
18
  [:bold, :bold_italic, :italic, :normal].each do |style|
19
19
  font example_font, :style => style
20
20
  text "I'm writing in #{example_font} (#{style})"
@@ -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
  class HighlightCallback
20
20
  def initialize(options)
21
21
  @color = options[:color]
@@ -40,7 +40,7 @@ Prawn::Example.generate(filename) do
40
40
  def render_in_front(fragment)
41
41
  @document.stroke_polygon(fragment.top_left, fragment.top_right,
42
42
  fragment.bottom_right, fragment.bottom_left)
43
-
43
+
44
44
  @document.fill_circle(fragment.top_left, @radius)
45
45
  @document.fill_circle(fragment.top_right, @radius)
46
46
  @document.fill_circle(fragment.bottom_right, @radius)
@@ -50,7 +50,7 @@ Prawn::Example.generate(filename) do
50
50
 
51
51
  highlight = HighlightCallback.new(:color => 'ffff00', :document => self)
52
52
  border = ConnectedBorderCallback.new(:radius => 2.5, :document => self)
53
-
53
+
54
54
  formatted_text [ { :text => "hello", :callback => highlight },
55
55
  { :text => " " },
56
56
  { :text => "world", :callback => border },
@@ -17,14 +17,14 @@
17
17
  # <code>:character_spacing</code> (additional space between the characters),
18
18
  # <code>:font</code> (the name of a registered font), <code>:color</code> (the
19
19
  # same input accepted by <code>fill_color</code> and <code>stroke_color</code>),
20
- # <code>:link</code> (an URL to create a link), and <code>:local</code>
20
+ # <code>:link</code> (an URL to create a link), and <code>:local</code>
21
21
  # (a link to a local file).
22
22
 
23
23
  require File.expand_path(File.join(File.dirname(__FILE__),
24
24
  %w[.. example_helper]))
25
25
 
26
26
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
27
- Prawn::Example.generate(filename) do
27
+ Prawn::ManualBuilder::Example.generate(filename) do
28
28
  formatted_text [ { :text => "Some bold. ", :styles => [:bold] },
29
29
  { :text => "Some italic. ", :styles => [:italic] },
30
30
  { :text => "Bold italic. ", :styles => [:bold, :italic] },
@@ -39,7 +39,7 @@ Prawn::Example.generate(filename) do
39
39
  :color => "0000FF",
40
40
  :local => "./local_file.txt" }
41
41
  ]
42
-
42
+
43
43
  formatted_text_box [ { :text => "Just your regular" },
44
44
  { :text => " text_box ", :font => "Courier" },
45
45
  { :text => "with some additional formatting options " +
@@ -17,29 +17,29 @@ 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
  move_cursor_to 50
22
22
  text "This text will flow to the next page. " * 20
23
-
23
+
24
24
  y_position = cursor - 50
25
25
  bounding_box([0, y_position], :width => 200, :height => 150) do
26
26
  transparent(0.5) { stroke_bounds }
27
27
  text "This text will flow along this bounding box we created for it. " * 5
28
28
  end
29
-
29
+
30
30
  bounding_box([300, y_position], :width => 200, :height => 150) do
31
31
  transparent(0.5) { stroke_bounds } # This will stroke on one page
32
-
32
+
33
33
  text "Now look what happens when the free flowing text reaches the end " +
34
34
  "of a bounding box that is narrower than the margin box." +
35
35
  " . " * 200 +
36
36
  "It continues on the next page as if the previous bounding box " +
37
37
  "was cloned. If we want it to have the same border as the one on " +
38
38
  "the previous page we will need to stroke the boundaries again."
39
-
39
+
40
40
  transparent(0.5) { stroke_bounds } # And this will stroke on the next
41
41
  end
42
-
42
+
43
43
  move_cursor_to 200
44
44
  span(350, :position => :center) do
45
45
  text "Span is a different kind of bounding box as it lets the text " +
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # Inline formatting gives you the option to format specific portions of a text.
4
4
  # It uses HTML-esque syntax inside the text string. Supported tags are:
5
5
  # <code>b</code> (bold), <code>i</code> (italic), <code>u</code> (underline),
@@ -15,25 +15,25 @@ 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
  %w[b i u strikethrough sub sup].each do |tag|
20
20
  text "Just your regular text <#{tag}>except this portion</#{tag}> " +
21
21
  "is using the #{tag} tag",
22
22
  :inline_format => true
23
23
  move_down 10
24
24
  end
25
-
25
+
26
26
  text "This <font size='18'>line</font> uses " +
27
27
  "<font name='Courier'>all the font tag</font> attributes in " +
28
28
  "<font character_spacing='2'>a single line</font>. ",
29
29
  :inline_format => true
30
30
  move_down 10
31
-
31
+
32
32
  text "Coloring in <color rgb='FF00FF'>both RGB</color> " +
33
33
  "<color c='100' m='0' y='0' k='0'>and CMYK</color>",
34
34
  :inline_format => true
35
35
  move_down 10
36
-
36
+
37
37
  text "This an external link to the " +
38
38
  "<u><link href='https://github.com/prawnpdf/prawn/wiki'>Prawn wiki" +
39
39
  "</link></u>",
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # Kerning is the process of adjusting the spacing between characters in a
4
4
  # proportional font. It is usually done with specific letter pairs. We can
5
5
  # switch it on and off if it is available with the current font. Just pass a
@@ -13,23 +13,23 @@ 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
  font_size(30) do
18
18
  text_box "With kerning:", :kerning => true, :at => [0, y - 40]
19
19
  text_box "Without kerning:", :kerning => false, :at => [0, y - 80]
20
-
20
+
21
21
  text_box "Tomato", :kerning => true, :at => [250, y - 40]
22
22
  text_box "Tomato", :kerning => false, :at => [250, y - 80]
23
-
23
+
24
24
  text_box "WAR", :kerning => true, :at => [400, y - 40]
25
25
  text_box "WAR", :kerning => false, :at => [400, y - 80]
26
-
26
+
27
27
  text_box "F.", :kerning => true, :at => [500, y - 40]
28
28
  text_box "F.", :kerning => false, :at => [500, y - 80]
29
29
  end
30
-
30
+
31
31
  move_down 80
32
-
32
+
33
33
  string = "What have you done to the space between the characters?"
34
34
  [-2, -1, 0, 0.5, 1, 2].each do |spacing|
35
35
  move_down 20
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # Leading is the additional space between lines of text.
4
4
  #
5
5
  # The leading can be set using the <code>default_leading</code> method which
@@ -12,14 +12,14 @@ 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
  string = "Hey, what did you do with the space between my lines? " * 10
17
17
  text string, :leading => 0
18
-
18
+
19
19
  move_down 20
20
20
  default_leading 5
21
21
  text string
22
-
22
+
23
23
  move_down 20
24
24
  text string, :leading => 10
25
25
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # Line wrapping happens on white space or hyphens. Soft hyphens can be used to
4
4
  # indicate where words can be hyphenated. Non-breaking spaces can be used to
5
5
  # display space without allowing for a break.
@@ -11,7 +11,7 @@ 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
  text "Hard hyphens:\n" +
16
16
  "Slip-sliding away, slip sliding awaaaay. You know the " +
17
17
  "nearer your destination the more you're slip-sliding away."
@@ -22,7 +22,7 @@ Prawn::Example.generate(filename) do
22
22
  "Slip slid#{shy}ing away, slip slid#{shy}ing away. You know the " +
23
23
  "nearer your destinat#{shy}ion the more you're slip slid#{shy}ing away."
24
24
  move_down 20
25
-
25
+
26
26
  nbsp = Prawn::Text::NBSP
27
27
  text "Non-breaking spaces:\n" +
28
28
  "Slip#{nbsp}sliding away, slip#{nbsp}sliding awaaaay. You know the " +
@@ -33,7 +33,7 @@ Prawn::Example.generate(filename) do
33
33
  long_text = "No word boundaries:\n更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。"
34
34
  text long_text
35
35
  move_down 20
36
-
36
+
37
37
  zwsp = Prawn::Text::ZWSP
38
38
  long_text = "Invisible word boundaries:\n更#{zwsp}可怕的#{zwsp}是,#{zwsp}同质化#{zwsp}竞争#{zwsp}对#{zwsp}手#{zwsp}可以#{zwsp}按照#{zwsp}URL#{zwsp}中#{zwsp}后面#{zwsp}这个#{zwsp}ID#{zwsp}来#{zwsp}遍历#{zwsp}您的#{zwsp}DB#{zwsp}中的#{zwsp}内容,#{zwsp}写个#{zwsp}小爬虫#{zwsp}把#{zwsp}你的#{zwsp}页面#{zwsp}上的#{zwsp}关#{zwsp}键#{zwsp}信#{zwsp}息顺#{zwsp}次#{zwsp}爬#{zwsp}下来#{zwsp}也#{zwsp}不是#{zwsp}什么#{zwsp}难事,#{zwsp}这样的话,#{zwsp}你#{zwsp}就#{zwsp}非常#{zwsp}被动了。#{zwsp}更#{zwsp}可怕的#{zwsp}是,#{zwsp}同质化#{zwsp}竞争#{zwsp}对#{zwsp}手#{zwsp}可以#{zwsp}按照#{zwsp}URL#{zwsp}中#{zwsp}后面#{zwsp}这个#{zwsp}ID#{zwsp}来#{zwsp}遍历#{zwsp}您的#{zwsp}DB#{zwsp}中的#{zwsp}内容,#{zwsp}写个#{zwsp}小爬虫#{zwsp}把#{zwsp}你的#{zwsp}页面#{zwsp}上的#{zwsp}关#{zwsp}键#{zwsp}信#{zwsp}息顺#{zwsp}次#{zwsp}爬#{zwsp}下来#{zwsp}也#{zwsp}不是#{zwsp}什么#{zwsp}难事,#{zwsp}这样的话,#{zwsp}你#{zwsp}就#{zwsp}非常#{zwsp}被动了。"
39
39
  text long_text
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+ #
3
3
  # Prawn strips all whitespace from the beginning and the end of strings so there
4
4
  # are two ways to indent paragraphs:
5
5
  #
@@ -14,11 +14,11 @@ require File.expand_path(File.join(File.dirname(__FILE__),
14
14
  %w[.. example_helper]))
15
15
 
16
16
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
17
- Prawn::Example.generate(filename) do
17
+ Prawn::ManualBuilder::Example.generate(filename) do
18
18
  # Using non-breaking spaces
19
19
  text " " * 10 + "This paragraph won't be indented. " * 10 +
20
20
  "\n#{Prawn::Text::NBSP * 10}" + "This one will with NBSP. " * 10
21
-
21
+
22
22
  move_down 20
23
23
  text "This paragraph will be indented. " * 10 +
24
24
  "\n" + "This one will too. " * 10,
@@ -21,17 +21,17 @@ require File.expand_path(File.join(File.dirname(__FILE__),
21
21
  %w[.. example_helper]))
22
22
 
23
23
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
24
- Prawn::Example.generate(filename) do
24
+ Prawn::ManualBuilder::Example.generate(filename) do
25
25
  draw_text "This draw_text line is absolute positioned. However don't " +
26
26
  "expect it to flow even if it hits the document border",
27
27
  :at => [200, 300]
28
-
28
+
29
29
  text_box "This is a text box, you can control where it will flow by " +
30
30
  "specifying the :height and :width options",
31
31
  :at => [100, 250],
32
32
  :height => 100,
33
33
  :width => 100
34
-
34
+
35
35
  text_box "Another text box with no :width option passed, so it will " +
36
36
  "flow to a new line whenever it reaches the right margin. ",
37
37
  :at => [200, 100]
@@ -12,17 +12,17 @@ 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
  # Registering a single TTF font
17
17
  font_families.update("DejaVu Sans" => {
18
18
  :normal => "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
19
19
  })
20
-
20
+
21
21
  font("DejaVu Sans") do
22
22
  text "Using the DejaVu Sans font providing only its name to the font method"
23
23
  end
24
24
  move_down 20
25
-
25
+
26
26
  # Registering a DFONT package
27
27
  font_path = "#{Prawn::DATADIR}/fonts/Panic+Sans.dfont"
28
28
  font_families.update("Panic Sans" => {
@@ -31,15 +31,15 @@ Prawn::Example.generate(filename) do
31
31
  :bold => { :file => font_path, :font => "PanicSans-Bold" },
32
32
  :bold_italic => { :file => font_path, :font => "PanicSans-BoldItalic" }
33
33
  })
34
-
34
+
35
35
  font "Panic Sans"
36
36
  text "Also using Panic Sans by providing only its name"
37
37
  move_down 20
38
-
38
+
39
39
  text "Taking <b>advantage</b> of the <i>inline formatting</i>",
40
40
  :inline_format => true
41
41
  move_down 20
42
-
42
+
43
43
  [:bold, :bold_italic, :italic, :normal].each do |style|
44
44
  text "Using the #{style} style option.",
45
45
  :style => style