prawn 0.11.1.pre → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. data/COPYING +2 -340
  2. data/HACKING +1 -1
  3. data/LICENSE +3 -3
  4. data/Rakefile +17 -6
  5. data/data/encodings/win_ansi.txt +1 -1
  6. data/data/images/prawn.png +0 -0
  7. data/data/pdfs/form.pdf +820 -0
  8. data/data/pdfs/multipage_template.pdf +127 -0
  9. data/examples/bounding_box/bounding_boxes.rb +4 -3
  10. data/examples/bounding_box/indentation.rb +2 -1
  11. data/examples/bounding_box/russian_boxes.rb +3 -2
  12. data/examples/bounding_box/stretched_nesting.rb +2 -1
  13. data/examples/general/background.rb +2 -1
  14. data/examples/general/canvas.rb +2 -1
  15. data/examples/general/context_sensitive_headers.rb +2 -1
  16. data/examples/general/float.rb +2 -1
  17. data/examples/general/margin.rb +2 -1
  18. data/examples/general/measurement_units.rb +2 -1
  19. data/examples/general/metadata-info.rb +2 -1
  20. data/examples/general/multi_page_layout.rb +2 -1
  21. data/examples/general/outlines.rb +2 -1
  22. data/examples/general/page_geometry.rb +2 -1
  23. data/examples/general/page_numbering.rb +27 -2
  24. data/examples/general/page_templates.rb +20 -0
  25. data/examples/general/repeaters.rb +2 -1
  26. data/examples/general/stamp.rb +4 -3
  27. data/examples/general/templates.rb +2 -1
  28. data/examples/graphics/basic_images.rb +2 -1
  29. data/examples/graphics/cmyk.rb +2 -1
  30. data/examples/graphics/curves.rb +4 -3
  31. data/examples/graphics/gradient.rb +23 -0
  32. data/examples/graphics/hexagon.rb +3 -2
  33. data/examples/graphics/image_fit.rb +3 -2
  34. data/examples/graphics/image_flow.rb +2 -1
  35. data/examples/graphics/image_position.rb +3 -2
  36. data/examples/graphics/line.rb +2 -1
  37. data/examples/graphics/png_types.rb +3 -2
  38. data/examples/graphics/polygons.rb +3 -2
  39. data/examples/graphics/remote_images.rb +2 -1
  40. data/examples/graphics/rounded_polygons.rb +2 -1
  41. data/examples/graphics/rounded_rectangle.rb +2 -1
  42. data/examples/graphics/ruport_style_helpers.rb +3 -2
  43. data/examples/graphics/stroke_bounds.rb +2 -1
  44. data/examples/graphics/stroke_cap_and_join.rb +2 -1
  45. data/examples/graphics/stroke_dash.rb +2 -1
  46. data/examples/graphics/transformations.rb +2 -1
  47. data/examples/graphics/transparency.rb +4 -3
  48. data/examples/grid/bounding_boxes.rb +2 -1
  49. data/examples/grid/column_gutter_grid.rb +2 -1
  50. data/examples/grid/multi_boxes.rb +2 -1
  51. data/examples/grid/show_grid.rb +2 -1
  52. data/examples/grid/simple_grid.rb +2 -1
  53. data/examples/m17n/chinese_text_wrapping.rb +2 -1
  54. data/examples/m17n/euro.rb +3 -2
  55. data/examples/m17n/full_win_ansi_character_list.rb +20 -0
  56. data/examples/m17n/sjis.rb +2 -1
  57. data/examples/m17n/utf8.rb +3 -2
  58. data/examples/m17n/win_ansi_charset.rb +2 -1
  59. data/examples/security/hello_foo.rb +2 -1
  60. data/examples/table/bill.rb +2 -1
  61. data/examples/table/borders.rb +25 -0
  62. data/examples/table/cell.rb +3 -2
  63. data/examples/table/checkerboard.rb +2 -1
  64. data/examples/table/header.rb +3 -2
  65. data/examples/table/inline_format_table.rb +2 -1
  66. data/examples/table/multi_page_table.rb +2 -1
  67. data/examples/table/simple_table.rb +2 -1
  68. data/examples/table/subtable.rb +2 -1
  69. data/examples/table/widths.rb +2 -1
  70. data/examples/text/alignment.rb +2 -1
  71. data/examples/text/character_spacing.rb +2 -1
  72. data/examples/text/dfont.rb +2 -1
  73. data/examples/text/family_based_styling.rb +3 -2
  74. data/examples/text/font_calculations.rb +2 -1
  75. data/examples/text/font_size.rb +2 -1
  76. data/examples/text/hyphenation.rb +2 -2
  77. data/examples/text/indent_paragraphs.rb +7 -5
  78. data/examples/text/inline_format.rb +7 -6
  79. data/examples/text/kerning.rb +2 -1
  80. data/examples/text/rendering_mode.rb +21 -0
  81. data/examples/text/rotated.rb +2 -1
  82. data/examples/text/shaped_text_box.rb +2 -1
  83. data/examples/text/simple_text.rb +2 -1
  84. data/examples/text/simple_text_ttf.rb +2 -1
  85. data/examples/text/span.rb +3 -2
  86. data/examples/text/text_box.rb +7 -5
  87. data/examples/text/text_box_returning_excess.rb +4 -3
  88. data/examples/text/text_flow.rb +2 -1
  89. data/lib/prawn.rb +1 -1
  90. data/lib/prawn/core/object_store.rb +42 -14
  91. data/lib/prawn/core/page.rb +22 -8
  92. data/lib/prawn/core/text.rb +141 -13
  93. data/lib/prawn/core/text/formatted/arranger.rb +39 -12
  94. data/lib/prawn/core/text/formatted/line_wrap.rb +205 -60
  95. data/lib/prawn/core/text/formatted/wrap.rb +72 -35
  96. data/lib/prawn/document.rb +174 -70
  97. data/lib/prawn/document/bounding_box.rb +122 -83
  98. data/lib/prawn/document/column_box.rb +113 -0
  99. data/lib/prawn/document/graphics_state.rb +90 -2
  100. data/lib/prawn/document/internals.rb +5 -3
  101. data/lib/prawn/errors.rb +5 -0
  102. data/lib/prawn/font.rb +4 -4
  103. data/lib/prawn/font/afm.rb +11 -0
  104. data/lib/prawn/font/ttf.rb +5 -0
  105. data/lib/prawn/graphics.rb +77 -14
  106. data/lib/prawn/graphics/cap_style.rb +13 -5
  107. data/lib/prawn/graphics/color.rb +54 -35
  108. data/lib/prawn/graphics/dash.rb +27 -16
  109. data/lib/prawn/graphics/gradient.rb +84 -0
  110. data/lib/prawn/graphics/join_style.rb +12 -3
  111. data/lib/prawn/graphics/transparency.rb +4 -4
  112. data/lib/prawn/images.rb +18 -160
  113. data/lib/prawn/images/jpg.rb +39 -0
  114. data/lib/prawn/images/png.rb +130 -0
  115. data/lib/prawn/repeater.rb +6 -13
  116. data/lib/prawn/security.rb +6 -1
  117. data/lib/prawn/stamp.rb +12 -4
  118. data/lib/prawn/table.rb +36 -4
  119. data/lib/prawn/table/cell.rb +224 -63
  120. data/lib/prawn/table/cell/text.rb +20 -10
  121. data/lib/prawn/table/cells.rb +23 -6
  122. data/lib/prawn/text.rb +54 -91
  123. data/lib/prawn/text/box.rb +29 -283
  124. data/lib/prawn/text/formatted/box.rb +349 -24
  125. data/lib/prawn/text/formatted/fragment.rb +63 -2
  126. data/lib/prawn/text/formatted/parser.rb +2 -1
  127. data/prawn.gemspec +21 -5
  128. data/spec/bounding_box_spec.rb +61 -28
  129. data/spec/cell_spec.rb +168 -30
  130. data/spec/document_spec.rb +187 -3
  131. data/spec/extensions/mocha.rb +45 -0
  132. data/spec/font_spec.rb +32 -1
  133. data/spec/formatted_text_arranger_spec.rb +35 -40
  134. data/spec/formatted_text_box_spec.rb +287 -443
  135. data/spec/formatted_text_fragment_spec.rb +87 -0
  136. data/spec/graphics_spec.rb +128 -12
  137. data/spec/grid_spec.rb +1 -1
  138. data/spec/images_spec.rb +11 -3
  139. data/spec/inline_formatted_text_parser_spec.rb +8 -0
  140. data/spec/line_wrap_spec.rb +200 -208
  141. data/spec/object_store_spec.rb +10 -0
  142. data/spec/outline_spec.rb +7 -3
  143. data/spec/repeater_spec.rb +58 -10
  144. data/spec/security_spec.rb +6 -0
  145. data/spec/spec_helper.rb +12 -8
  146. data/spec/stamp_spec.rb +52 -1
  147. data/spec/stroke_styles_spec.rb +30 -0
  148. data/spec/table_spec.rb +93 -3
  149. data/spec/template_spec.rb +132 -6
  150. data/spec/text_at_spec.rb +14 -4
  151. data/spec/text_box_spec.rb +309 -70
  152. data/spec/text_rendering_mode_spec.rb +45 -0
  153. data/spec/text_spec.rb +60 -17
  154. data/spec/text_with_inline_formatting_spec.rb +4 -162
  155. metadata +241 -241
  156. data/lib/prawn/core/text/line_wrap.rb +0 -211
  157. data/lib/prawn/core/text/wrap.rb +0 -82
  158. data/vendor/pdf-inspector/README +0 -18
  159. data/vendor/pdf-inspector/lib/pdf/inspector.rb +0 -26
  160. data/vendor/pdf-inspector/lib/pdf/inspector/extgstate.rb +0 -18
  161. data/vendor/pdf-inspector/lib/pdf/inspector/graphics.rb +0 -131
  162. data/vendor/pdf-inspector/lib/pdf/inspector/page.rb +0 -25
  163. data/vendor/pdf-inspector/lib/pdf/inspector/text.rb +0 -46
  164. data/vendor/pdf-inspector/lib/pdf/inspector/xobject.rb +0 -19
  165. data/vendor/ttfunk/data/fonts/DejaVuSans.ttf +0 -0
  166. data/vendor/ttfunk/data/fonts/comicsans.ttf +0 -0
  167. data/vendor/ttfunk/example.rb +0 -45
  168. data/vendor/ttfunk/lib/ttfunk.rb +0 -102
  169. data/vendor/ttfunk/lib/ttfunk/directory.rb +0 -17
  170. data/vendor/ttfunk/lib/ttfunk/encoding/mac_roman.rb +0 -88
  171. data/vendor/ttfunk/lib/ttfunk/encoding/windows_1252.rb +0 -69
  172. data/vendor/ttfunk/lib/ttfunk/reader.rb +0 -44
  173. data/vendor/ttfunk/lib/ttfunk/resource_file.rb +0 -78
  174. data/vendor/ttfunk/lib/ttfunk/subset.rb +0 -18
  175. data/vendor/ttfunk/lib/ttfunk/subset/base.rb +0 -141
  176. data/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb +0 -50
  177. data/vendor/ttfunk/lib/ttfunk/subset/unicode.rb +0 -48
  178. data/vendor/ttfunk/lib/ttfunk/subset/unicode_8bit.rb +0 -63
  179. data/vendor/ttfunk/lib/ttfunk/subset/windows_1252.rb +0 -55
  180. data/vendor/ttfunk/lib/ttfunk/subset_collection.rb +0 -72
  181. data/vendor/ttfunk/lib/ttfunk/table.rb +0 -46
  182. data/vendor/ttfunk/lib/ttfunk/table/cmap.rb +0 -34
  183. data/vendor/ttfunk/lib/ttfunk/table/cmap/format00.rb +0 -54
  184. data/vendor/ttfunk/lib/ttfunk/table/cmap/format04.rb +0 -126
  185. data/vendor/ttfunk/lib/ttfunk/table/cmap/subtable.rb +0 -79
  186. data/vendor/ttfunk/lib/ttfunk/table/glyf.rb +0 -64
  187. data/vendor/ttfunk/lib/ttfunk/table/glyf/compound.rb +0 -81
  188. data/vendor/ttfunk/lib/ttfunk/table/glyf/simple.rb +0 -37
  189. data/vendor/ttfunk/lib/ttfunk/table/head.rb +0 -44
  190. data/vendor/ttfunk/lib/ttfunk/table/hhea.rb +0 -41
  191. data/vendor/ttfunk/lib/ttfunk/table/hmtx.rb +0 -47
  192. data/vendor/ttfunk/lib/ttfunk/table/kern.rb +0 -79
  193. data/vendor/ttfunk/lib/ttfunk/table/kern/format0.rb +0 -62
  194. data/vendor/ttfunk/lib/ttfunk/table/loca.rb +0 -43
  195. data/vendor/ttfunk/lib/ttfunk/table/maxp.rb +0 -40
  196. data/vendor/ttfunk/lib/ttfunk/table/name.rb +0 -125
  197. data/vendor/ttfunk/lib/ttfunk/table/os2.rb +0 -78
  198. data/vendor/ttfunk/lib/ttfunk/table/post.rb +0 -91
  199. data/vendor/ttfunk/lib/ttfunk/table/post/format10.rb +0 -43
  200. data/vendor/ttfunk/lib/ttfunk/table/post/format20.rb +0 -35
  201. data/vendor/ttfunk/lib/ttfunk/table/post/format25.rb +0 -23
  202. data/vendor/ttfunk/lib/ttfunk/table/post/format30.rb +0 -17
  203. data/vendor/ttfunk/lib/ttfunk/table/post/format40.rb +0 -17
  204. data/vendor/ttfunk/lib/ttfunk/table/simple.rb +0 -14
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # Draws and fills a Hexagon using Document#polygon
4
4
  #
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
6
7
 
7
8
  pdf = Prawn::Document.new
8
9
 
@@ -10,4 +11,4 @@ pdf.fill_color "ff0000"
10
11
  pdf.fill_polygon [100, 250], [200, 300], [300, 250],
11
12
  [300, 150], [200, 100], [100, 150]
12
13
 
13
- pdf.render_file "hexagon.pdf"
14
+ pdf.render_file "hexagon.pdf"
@@ -4,7 +4,8 @@
4
4
  # The image will be scaled down to fit within the box, while preserving
5
5
  # the aspect ratio.
6
6
  #
7
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
7
+ require File.expand_path(File.join(File.dirname(__FILE__),
8
+ %w[.. example_helper]))
8
9
 
9
10
  Prawn::Document.generate("image_fit.pdf", :page_layout => :landscape) do
10
11
 
@@ -12,4 +13,4 @@ Prawn::Document.generate("image_fit.pdf", :page_layout => :landscape) do
12
13
  stroke_rectangle [50,450], 200, 200
13
14
  image pigs, :at => [50,450], :fit => [200,200]
14
15
 
15
- end
16
+ end
@@ -5,7 +5,8 @@
5
5
  # useful when used in combination with flowing text, where the exact final
6
6
  # position of the image is not known ahead of time.
7
7
  #
8
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
8
+ require File.expand_path(File.join(File.dirname(__FILE__),
9
+ %w[.. example_helper]))
9
10
 
10
11
  Prawn::Document.generate("image-flow.pdf", :page_layout => :landscape) do
11
12
  self.font_size = 8
@@ -2,8 +2,9 @@
2
2
  #
3
3
  # Demonstrates vertical and horizontal positioning of images.
4
4
  #
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
6
-
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
7
+
7
8
  Prawn::Document.generate("image_position.pdf", :page_layout => :landscape) do
8
9
 
9
10
  dice = "#{Prawn::BASEDIR}/data/images/dice.png"
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # The very first Prawn example. Here for nostalgia's sake.
4
4
  #
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
6
7
 
7
8
  pdf = Prawn::Document.new
8
9
  pdf.line_width = 10
@@ -3,7 +3,8 @@
3
3
  # PNG files come in different flavours - 5 of them. This example embeds
4
4
  # one of each type as proof that they all work.
5
5
  #
6
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
6
+ require File.expand_path(File.join(File.dirname(__FILE__),
7
+ %w[.. example_helper]))
7
8
 
8
9
  images = [
9
10
  ["Type 0", "#{Prawn::BASEDIR}/data/images/web-links.png"],
@@ -19,4 +20,4 @@ Prawn::Document.generate("png_types.pdf", :page_size => "A5") do
19
20
  text header
20
21
  image file, :at => [50,450]
21
22
  end
22
- end
23
+ end
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # Basic polygon drawing example. See also: hexagon.rb
4
4
  #
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
6
7
 
7
8
  pdf = Prawn::Document.new
8
9
 
@@ -13,4 +14,4 @@ pdf = Prawn::Document.new
13
14
  pdf.stroke_rectangle [0,600], 5*i, 10*i
14
15
  end
15
16
 
16
- pdf.render_file "pretty_polygons.pdf"
17
+ pdf.render_file "pretty_polygons.pdf"
@@ -3,7 +3,8 @@
3
3
  # Demonstrates how to use open-uri and Document#image to embed remote image
4
4
  # files.
5
5
  #
6
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
6
+ require File.expand_path(File.join(File.dirname(__FILE__),
7
+ %w[.. example_helper]))
7
8
 
8
9
  require "open-uri"
9
10
 
@@ -1,4 +1,5 @@
1
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
1
+ require File.expand_path(File.join(File.dirname(__FILE__),
2
+ %w[.. example_helper]))
2
3
 
3
4
  def radian(degree)
4
5
  Math::PI/180*degree
@@ -3,7 +3,8 @@
3
3
  # Rounded rectangle example demonstrating both stroke and stroke and fill.
4
4
  # A rectangle with rounded join_style is added just for comparison.
5
5
  #
6
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
6
+ require File.expand_path(File.join(File.dirname(__FILE__),
7
+ %w[.. example_helper]))
7
8
 
8
9
  pdf = Prawn::Document.new
9
10
  pdf.font_size 8
@@ -3,7 +3,8 @@
3
3
  # These helpers will be familiar to Ruport users, and now are supported
4
4
  # directly in Prawn. Run the example to see how they work.
5
5
  #
6
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
6
+ require File.expand_path(File.join(File.dirname(__FILE__),
7
+ %w[.. example_helper]))
7
8
 
8
9
  # Demonstrates some features stolen from Ruport::Formatter::PDF
9
10
  Prawn::Document.generate("ruport.pdf") do
@@ -16,4 +17,4 @@ Prawn::Document.generate("ruport.pdf") do
16
17
  stroke_horizontal_line 50, 100
17
18
  stroke_horizontal_line 50, 100, :at => 300
18
19
  stroke_vertical_line 300, 50, :at => 250
19
- end
20
+ end
@@ -8,7 +8,8 @@
8
8
  # Feature borrowed from Josh Knowle's pt at:
9
9
  # http://github.com/joshknowles/pt/tree/master
10
10
  #
11
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
11
+ require File.expand_path(File.join(File.dirname(__FILE__),
12
+ %w[.. example_helper]))
12
13
 
13
14
  Prawn::Document.generate("stroke_bounds.pdf") do
14
15
  stroke_bounds
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # Stroke dashing can be applied to any line or curve
4
4
 
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
6
7
 
7
8
  Prawn::Document.generate("stroke_cap_and_join.pdf") do
8
9
  self.line_width = 25
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # Stroke dashing can be applied to any line or curve
4
4
 
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
6
7
 
7
8
  Prawn::Document.generate("stroke_dash.pdf") do
8
9
  self.line_width = 1
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # Demonstrates transformations
4
4
  #
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
6
7
 
7
8
  Prawn::Document.generate "transformations.pdf" do |pdf|
8
9
  width = 50
@@ -2,15 +2,16 @@
2
2
  #
3
3
  # Demonstrate use of transparency
4
4
  #
5
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
5
+ require File.expand_path(File.join(File.dirname(__FILE__),
6
+ %w[.. example_helper]))
6
7
 
7
8
  Prawn::Document.generate("transparency.pdf") do
8
9
  fill_color("ff0000")
9
- fill_circle_at([200, 200], :radius => 200)
10
+ fill_circle([200, 200], 200)
10
11
  transparent(0.5, 1) do
11
12
  fill_color("000000")
12
13
  stroke_color("ffffff")
13
- fill_and_stroke_circle_at([300, 300], :radius => 200)
14
+ fill_and_stroke_circle([300, 300], 200)
14
15
  fill_color("ffffff")
15
16
  text "transparency " * 150, :size => 18
16
17
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate('bounding_box_grid.pdf') do |p|
6
7
  p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate('column_gutter_grid.pdf') do |p|
6
7
  p.define_grid(:columns => 3, :rows => 10, :column_gutter => 10)
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate('multi_boxes.pdf') do |p|
6
7
  p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate('show_grid.pdf') do |p|
6
7
  p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate('simple_grid.pdf') do |p|
6
7
  p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
2
  #
3
3
  #
4
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
4
+ require File.expand_path(File.join(File.dirname(__FILE__),
5
+ %w[.. example_helper]))
5
6
 
6
7
  start = Time.now
7
8
  Prawn::Document.generate("chinese_flow.pdf") do
@@ -8,8 +8,9 @@
8
8
  # If you need precision spacing, use a TTF file instead and the issue will
9
9
  # go away.
10
10
  #
11
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
11
+ require File.expand_path(File.join(File.dirname(__FILE__),
12
+ %w[.. example_helper]))
12
13
 
13
14
  Prawn::Document.generate "euro.pdf" do
14
15
  text "A Euro! € ©", :size => 32
15
- end
16
+ end
@@ -0,0 +1,20 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path(File.join(File.dirname(__FILE__),
3
+ %w[.. example_helper]))
4
+
5
+ FONT_SIZE = 9.5
6
+
7
+ Prawn::Document.generate("missing-win-ansi-mappings.pdf") do
8
+ # I generated this as a test to see what characters were missing from
9
+ # data/encodings/win_ansi.txt. To find missing characters, search for
10
+ # underscore (_). Any underscore except for #95 is a missing encoding.
11
+ #
12
+ # http://www.alanwood.net/demos/ansi.html was a helpful list of WinAnsi and
13
+ # corresponding Unicode hex values for any characters that were missing
14
+
15
+ a = [[32, " "], [33, "!"], [34, "\""], [35, "#"], [36, "$"], [37, "%"], [38, "&"], [39, "'"], [40, "("], [41, ")"], [42, "*"], [43, "+"], [44, ","], [45, "-"], [46, "."], [47, "/"], [48, "0"], [49, "1"], [50, "2"], [51, "3"], [52, "4"], [53, "5"], [54, "6"], [55, "7"], [56, "8"], [57, "9"], [58, ":"], [59, ";"], [60, "<"], [61, "="], [62, ">"], [63, "?"], [64, "@"], [65, "A"], [66, "B"], [67, "C"], [68, "D"], [69, "E"], [70, "F"], [71, "G"], [72, "H"], [73, "I"], [74, "J"], [75, "K"], [76, "L"], [77, "M"], [78, "N"], [79, "O"], [80, "P"], [81, "Q"], [82, "R"], [83, "S"], [84, "T"], [85, "U"], [86, "V"], [87, "W"], [88, "X"], [89, "Y"], [90, "Z"], [91, "["], [92, "\\"], [93, "]"], [94, "^"], [95, "_"], [96, "`"], [97, "a"], [98, "b"], [99, "c"], [100, "d"], [101, "e"], [102, "f"], [103, "g"], [104, "h"], [105, "i"], [106, "j"], [107, "k"], [108, "l"], [109, "m"], [110, "n"], [111, "o"], [112, "p"], [113, "q"], [114, "r"], [115, "s"], [116, "t"], [117, "u"], [118, "v"], [119, "w"], [120, "x"], [121, "y"], [122, "z"], [123, "{"], [124, "|"], [125, "}"], [126, "~"], [127, " "], [128, "€"], [129, " "], [130, "‚"], [131, "ƒ"], [132, "„"], [133, "…"], [134, "†"], [135, "‡"], [136, "ˆ"], [137, "‰"], [138, "Š"], [139, "‹"], [140, "Œ"], [141, " "], [142, "Ž"], [143, " "], [144, " "], [145, "‘"], [146, "’"], [147, "“"], [148, "”"], [149, "•"], [150, "–"], [151, "—"], [152, "˜"], [153, "™"], [154, "š"], [155, "›"], [156, "œ"], [157, " "], [158, "ž"], [159, "Ÿ"], [160, " "], [161, "¡"], [162, "¢"], [163, "£"], [164, "¤"], [165, "¥"], [166, "¦"], [167, "§"], [168, "¨"], [169, "©"], [170, "ª"], [171, "«"], [172, "¬"], [173, "1"], [174, "®"], [175, "¯"], [176, "°"], [177, "±"], [178, "²"], [179, "³"], [180, "´"], [181, "µ"], [182, "¶"], [183, "·"], [184, "¸"], [185, "¹"], [186, "º"], [187, "»"], [188, "¼"], [189, "½"], [190, "¾"], [191, "¿"], [192, "À"], [193, "Á"], [194, "Â"], [195, "Ã"], [196, "Ä"], [197, "Å"], [198, "Æ"], [199, "Ç"], [200, "È"], [201, "É"], [202, "Ê"], [203, "Ë"], [204, "Ì"], [205, "Í"], [206, "Î"], [207, "Ï"], [208, "Ð"], [209, "Ñ"], [210, "Ò"], [211, "Ó"], [212, "Ô"], [213, "Õ"], [214, "Ö"], [215, "×"], [216, "Ø"], [217, "Ù"], [218, "Ú"], [219, "Û"], [220, "Ü"], [221, "Ý"], [222, "Þ"], [223, "ß"], [224, "à"], [225, "á"], [226, "â"], [227, "ã"], [228, "ä"], [229, "å"], [230, "æ"], [231, "ç"], [232, "è"], [233, "é"], [234, "ê"], [235, "ë"], [236, "ì"], [237, "í"], [238, "î"], [239, "ï"], [240, "ð"], [241, "ñ"], [242, "ò"], [243, "ó"], [244, "ô"], [245, "õ"], [246, "ö"], [247, "÷"], [248, "ø"], [249, "ù"], [250, "ú"], [251, "û"], [252, "ü"], [253, "ý"], [254, "þ"], [255, "ÿ"]]
16
+
17
+ a.each do |i, char|
18
+ text "#{i} #{char}"
19
+ end
20
+ end
@@ -10,7 +10,8 @@
10
10
  # font to include japanese glyphs. On 1.8.x comaptible VMs, an exception
11
11
  # will be raised.
12
12
 
13
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
13
+ require File.expand_path(File.join(File.dirname(__FILE__),
14
+ %w[.. example_helper]))
14
15
 
15
16
  begin
16
17
  ruby_19 do
@@ -3,11 +3,12 @@
3
3
  # Shows that Prawn works out of the box with UTF-8 text, so long as you use
4
4
  # a TTF file with the necessary glyphs for your content.
5
5
  #
6
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
6
+ require File.expand_path(File.join(File.dirname(__FILE__),
7
+ %w[.. example_helper]))
7
8
 
8
9
  Prawn::Document.generate("utf8.pdf") do
9
10
  font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
10
11
  text "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει." * 20
11
12
  end
12
13
 
13
-
14
+
@@ -4,7 +4,8 @@
4
4
  # in fonts, along with their character widths and WinAnsi codes. Be sure
5
5
  # to pass these glyphs as UTF-8, and Prawn will transcode them for you.
6
6
  #
7
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
7
+ require File.expand_path(File.join(File.dirname(__FILE__),
8
+ %w[.. example_helper]))
8
9
 
9
10
  FONT_SIZE = 9.5
10
11
 
@@ -1,4 +1,5 @@
1
- require File.join(File.dirname(__FILE__), "..", "example_helper")
1
+ require File.expand_path(File.join(File.dirname(__FILE__),
2
+ %w[.. example_helper]))
2
3
 
3
4
  Prawn::Document.generate("security_hello_foo.pdf") do
4
5
  text "Hello, world!"
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  #
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate("bill.pdf") do
6
7
 
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ #
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
5
+
6
+ Prawn::Document.generate("borders.pdf") do |pdf|
7
+ pdf.text "This example demonstrates alignment of the background and " +
8
+ "borders, including proper corner alignment without overlap."
9
+ pdf.move_down 20
10
+
11
+ pdf.cell :content => "all borders", :background_color => 'ff0000'
12
+ pdf.move_down 15
13
+
14
+ [:top, :bottom, :left, :right].each do |border|
15
+ y = pdf.cursor
16
+ pdf.cell :content => "no #{border} border", :background_color => 'ff0000',
17
+ :borders => ([:top, :bottom, :left, :right] - [border])
18
+ pdf.cell :content => "#{border} border 0", :background_color => 'ff0000',
19
+ :"border_#{border}_width" => 0, :at => [150, y]
20
+ pdf.cell :content => "#{border} border 2", :background_color => 'ff0000',
21
+ :"border_#{border}_width" => 2, :at => [300, y]
22
+ pdf.move_down 15
23
+ end
24
+ end
25
+
@@ -5,8 +5,9 @@
5
5
  # building your own table implementation from scratch or heavily modify
6
6
  # the existing table system.
7
7
  #
8
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
8
+ require File.expand_path(File.join(File.dirname(__FILE__),
9
+ %w[.. example_helper]))
9
10
 
10
11
  Prawn::Document.generate("cell.pdf") do
11
- cell :content => "test", :padding => 10, :style => :bold, :size => 7
12
+ cell :content => "test", :padding => 10, :font_style => :bold, :size => 7
12
13
  end
@@ -3,7 +3,8 @@
3
3
  # Shows how to use the style() method with a block to style each cell with
4
4
  # custom code.
5
5
 
6
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
6
+ require File.expand_path(File.join(File.dirname(__FILE__),
7
+ %w[.. example_helper]))
7
8
 
8
9
  Prawn::Document.generate("checkerboard.pdf") do
9
10
 
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  #
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate("header.pdf") do
6
7
 
@@ -8,7 +9,7 @@ Prawn::Document.generate("header.pdf") do
8
9
  data = ["Bender Bending Rodriguez", "Bender"]
9
10
 
10
11
  table([header] + [data] * 50, :header => true) do
11
- row(0).style(:style => :bold, :background_color => 'cccccc')
12
+ row(0).style(:font_style => :bold, :background_color => 'cccccc')
12
13
  end
13
14
 
14
15
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  #
3
- require "#{File.dirname(__FILE__)}/../example_helper.rb"
3
+ require File.expand_path(File.join(File.dirname(__FILE__),
4
+ %w[.. example_helper]))
4
5
 
5
6
  Prawn::Document.generate("inline_format_table.pdf") do
6
7