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
@@ -15,6 +15,8 @@ require File.expand_path(File.join(File.dirname(__FILE__),
15
15
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
16
16
  Prawn::Example.generate(filename) do
17
17
  stroke_axis
18
+
19
+ stroke_color "ff0000"
18
20
 
19
21
  stroke do
20
22
  # just lower the current y position
@@ -1,12 +1,15 @@
1
1
  # encoding: utf-8
2
2
  #
3
3
  # To produce this manual we use the <code>stroke_axis</code> helper method
4
- # within examples but it is not from the Prawn API. It is defined on this file:
5
- #
6
- # https://github.com/prawnpdf/prawn/blob/master/manual/example_helper.rb
4
+ # within the examples.
7
5
  #
8
6
  # <code>stroke_axis</code> prints the x and y axis for the current bounding box
9
- # with markers in 100 increments
7
+ # with markers in 100 increments. The defaults can be changed with various
8
+ # options.
9
+ #
10
+ # Note that the examples define a custom <code>:height</code> option so that
11
+ # only the example canvas is used (as seen with the output of the first line of
12
+ # the example code).
10
13
  #
11
14
  require File.expand_path(File.join(File.dirname(__FILE__),
12
15
  %w[.. example_helper]))
@@ -14,4 +17,8 @@ require File.expand_path(File.join(File.dirname(__FILE__),
14
17
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
15
18
  Prawn::Example.generate(filename) do
16
19
  stroke_axis
20
+ stroke_axis(:at => [70, 70], :height => 200, :step_length => 50,
21
+ :negative_axes_length => 5, :color => '0000FF')
22
+ stroke_axis(:at => [140, 140], :width => 200, :height => cursor.to_i - 140,
23
+ :step_length => 20, :negative_axes_length => 40, :color => 'FF00')
17
24
  end
@@ -1,14 +1,17 @@
1
1
  # encoding: utf-8
2
2
  #
3
- # This sets the dashed pattern for lines and curves.
4
- #
5
- # The (dash) length defines how long each dash will be.
3
+ # This sets the dashed pattern for lines and curves. The (dash) length defines
4
+ # how long each dash will be.
6
5
  #
7
6
  # The <code>:space</code> option defines the length of the space between the
8
7
  # dashes.
9
8
  #
10
9
  # The <code>:phase</code> option defines the start point of the sequence of
11
- # dashes and spaces.
10
+ # dashes and spaces.
11
+ #
12
+ # Complex dash patterns can be specified by using an array with alternating
13
+ # dash/gap lengths for the first parameter (note that the <code>:space</code>
14
+ # option is ignored in this case).
12
15
  #
13
16
  require File.expand_path(File.join(File.dirname(__FILE__),
14
17
  %w[.. example_helper]))
@@ -16,27 +19,29 @@ require File.expand_path(File.join(File.dirname(__FILE__),
16
19
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
17
20
  Prawn::Example.generate(filename) do
18
21
  stroke_axis
19
-
22
+
23
+ dash([1, 2, 3, 2, 1, 5], :phase => 6)
24
+ stroke_horizontal_line 50, 500, :at => 230
25
+ dash([1, 2, 3, 4, 5, 6, 7, 8])
26
+ stroke_horizontal_line 50, 500, :at => 220
27
+
20
28
  base_y = 210
21
-
29
+
22
30
  24.times do |i|
23
31
  length = (i / 4) + 1
24
32
  space = length # space between dashes same length as dash
25
33
  phase = 0 # start with dash
26
-
34
+
27
35
  case i % 4
28
- when 0
29
- base_y -= 5
30
- when 1
31
- phase = length # start with space between dashes
32
- when 2
33
- space = length * 0.5 # space between dashes half as long as dash
36
+ when 0 then base_y -= 5
37
+ when 1 then phase = length # start with space between dashes
38
+ when 2 then space = length * 0.5 # space between dashes half as long as dash
34
39
  when 3
35
40
  space = length * 0.5 # space between dashes half as long as dash
36
41
  phase = length # start with space between dashes
37
42
  end
38
43
  base_y -= 5
39
-
44
+
40
45
  dash(length, :space => space, :phase => phase)
41
46
  stroke_horizontal_line 50, 500, :at => base_y - (2 * i)
42
47
  end
@@ -22,5 +22,21 @@ Prawn::Example.generate(filename) do
22
22
  :font => 'Courier',
23
23
  :size => 60}
24
24
  ], :at => [170, cursor - 160])
25
+
26
+ if Dir.exist?("#{Prawn::BASEDIR}/.git")
27
+ #long git commit hash
28
+ #commit = `git show --pretty=%H`
29
+ #short git commit hash
30
+ commit = `git show --pretty=%h`
31
+ git_commit = "git commit: #{commit}"
32
+ else
33
+ git_commit = ""
34
+ end
35
+
36
+ formatted_text_box([ {:text => "Last Update: #{Time.now.strftime("%Y-%m-%d")}\n"+
37
+ "Prawn Version: #{Prawn::VERSION}\n"+
38
+ git_commit,
39
+ :size => 12}
40
+ ], :at => [390, cursor - 620])
25
41
 
26
42
  end
@@ -3,19 +3,16 @@
3
3
  # Generates the Prawn by example manual.
4
4
  #
5
5
 
6
- Encoding.default_external = "UTF-8" if defined? Encoding
6
+ Encoding.default_external = Encoding::UTF_8
7
7
 
8
8
  require File.expand_path(File.join(File.dirname(__FILE__),
9
9
  %w[.. example_helper]))
10
10
 
11
11
  Prawn::Example.generate("manual.pdf",
12
- :optimize_objects => true,
13
- :compress => false,
14
12
  :skip_page_creation => true,
15
13
  :page_size => "FOLIO") do
16
14
 
17
15
  load_page "cover"
18
- load_page "foreword"
19
16
  load_page "how_to_read_this_manual"
20
17
 
21
18
  # Core chapters
@@ -31,6 +28,5 @@ Prawn::Example.generate("manual.pdf",
31
28
  load_package "document_and_page_options"
32
29
  load_package "outline"
33
30
  load_package "repeatable_content"
34
- load_package "templates"
35
31
  load_package "security"
36
32
  end
@@ -14,12 +14,12 @@ Prawn::Example.generate(filename) do
14
14
  :normal => { :file => file, :font => "Kai" }
15
15
  }
16
16
 
17
- file = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
18
- font_families["Action Man"] = {
19
- :normal => { :file => file, :font => "ActionMan" },
17
+ file = "#{Prawn::DATADIR}/fonts/Panic+Sans.dfont"
18
+ font_families["Panic Sans"] = {
19
+ :normal => { :file => file, :font => "PanicSans" },
20
20
  }
21
21
 
22
- font("Action Man") do
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 " +
25
25
  "current font and then moving through the fallback fonts from left " +
@@ -17,9 +17,9 @@
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>:anchor</code> (a
21
- # destination inside the document).
22
- #
20
+ # <code>:link</code> (an URL to create a link), and <code>:local</code>
21
+ # (a link to a local file).
22
+
23
23
  require File.expand_path(File.join(File.dirname(__FILE__),
24
24
  %w[.. example_helper]))
25
25
 
@@ -35,9 +35,9 @@ Prawn::Example.generate(filename) do
35
35
  { :text => "Link to the wiki. ",
36
36
  :color => "0000FF",
37
37
  :link => "https://github.com/prawnpdf/prawn/wiki" },
38
- { :text => "Link to the Text Reference. " ,
38
+ { :text => "Link to a local file. ",
39
39
  :color => "0000FF",
40
- :anchor => "Text Reference" }
40
+ :local => "./local_file.txt" }
41
41
  ]
42
42
 
43
43
  formatted_text_box [ { :text => "Just your regular" },
@@ -9,8 +9,7 @@
9
9
  # The following tags accept specific attributes: <code>font</code> accepts
10
10
  # <code>size</code>, <code>name</code>, and <code>character_spacing</code>;
11
11
  # <code>color</code> accepts <code>rgb</code> and <code>cmyk</code>;
12
- # <code>link</code> accepts <code>href</code> for external links and
13
- # <code>anchor</code> for internal links.
12
+ # <code>link</code> accepts <code>href</code> for external links.
14
13
  #
15
14
  require File.expand_path(File.join(File.dirname(__FILE__),
16
15
  %w[.. example_helper]))
@@ -37,7 +36,6 @@ Prawn::Example.generate(filename) do
37
36
 
38
37
  text "This an external link to the " +
39
38
  "<u><link href='https://github.com/prawnpdf/prawn/wiki'>Prawn wiki" +
40
- "</link></u> and this is a link to the " +
41
- "<u><link anchor='Text Reference'>Text Reference</link></u> anchor",
39
+ "</link></u>",
42
40
  :inline_format => true
43
41
  end
@@ -14,26 +14,26 @@ require File.expand_path(File.join(File.dirname(__FILE__),
14
14
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
15
15
  Prawn::Example.generate(filename) do
16
16
  # Registering a single TTF font
17
- font_families.update("Chalkboard" => {
18
- :normal => "#{Prawn::DATADIR}/fonts/Chalkboard.ttf"
17
+ font_families.update("DejaVu Sans" => {
18
+ :normal => "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
19
19
  })
20
20
 
21
- font("Chalkboard") do
22
- text "Using the Chalkboard font providing only its name to the font method"
21
+ font("DejaVu Sans") do
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
- font_path = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
28
- font_families.update("Action Man" => {
29
- :normal => { :file => font_path, :font => "ActionMan" },
30
- :italic => { :file => font_path, :font => "ActionMan-Italic" },
31
- :bold => { :file => font_path, :font => "ActionMan-Bold" },
32
- :bold_italic => { :file => font_path, :font => "ActionMan-BoldItalic" }
27
+ font_path = "#{Prawn::DATADIR}/fonts/Panic+Sans.dfont"
28
+ font_families.update("Panic Sans" => {
29
+ :normal => { :file => font_path, :font => "PanicSans" },
30
+ :italic => { :file => font_path, :font => "PanicSans-Italic" },
31
+ :bold => { :file => font_path, :font => "PanicSans-Bold" },
32
+ :bold_italic => { :file => font_path, :font => "PanicSans-BoldItalic" }
33
33
  })
34
34
 
35
- font "Action Man"
36
- text "Also using the Action Man by providing only its name"
35
+ font "Panic Sans"
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>",
@@ -19,8 +19,8 @@ require File.expand_path(File.join(File.dirname(__FILE__),
19
19
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
20
20
  Prawn::Example.generate(filename) do
21
21
  # Using a TTF font file
22
- font("#{Prawn::DATADIR}/fonts/Chalkboard.ttf") do
23
- text "Written with the Chalkboard TTF font."
22
+ font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf") do
23
+ text "Written with the DejaVu Sans TTF font."
24
24
  end
25
25
  move_down 20
26
26
 
@@ -28,8 +28,8 @@ Prawn::Example.generate(filename) do
28
28
  move_down 20
29
29
 
30
30
  # Using an DFONT font file
31
- font("#{Prawn::DATADIR}/fonts/Action Man.dfont") do
32
- text "Written with the Action Man DFONT font"
31
+ font("#{Prawn::DATADIR}/fonts/Panic+Sans.dfont") do
32
+ text "Written with the Panic Sans DFONT font"
33
33
  end
34
34
  move_down 20
35
35
 
@@ -14,7 +14,6 @@ Prawn::Example.generate("text.pdf", :page_size => "FOLIO") do
14
14
  s.example "positioned_text"
15
15
  s.example "text_box_overflow"
16
16
  s.example "text_box_excess"
17
- s.example "group"
18
17
  s.example "column_box"
19
18
  end
20
19
 
@@ -59,7 +58,6 @@ Prawn::Example.generate("text.pdf", :page_size => "FOLIO") do
59
58
  list( "Text that flows from page to page automatically starting new pages when necessary",
60
59
  "How to use text boxes and place them on specific positions",
61
60
  "What to do when a text box is too small to fit its content",
62
- "How to proceed when you want to prevent paragraphs from splitting between pages",
63
61
  "Flowing text in columns",
64
62
  "How to change the text style configuring font, size, alignment and many other settings",
65
63
  "How to style specific portions of a text with inline styling and formatted text",
@@ -3,27 +3,35 @@ Gem::Specification.new do |spec|
3
3
  spec.version = File.read(File.expand_path('VERSION', File.dirname(__FILE__))).strip
4
4
  spec.platform = Gem::Platform::RUBY
5
5
  spec.summary = "A fast and nimble PDF generator for Ruby"
6
- spec.files = Dir.glob("{examples,lib,spec,data,manual}/**/**/*") +
7
- ["Rakefile", "prawn.gemspec", "COPYING", "LICENSE", "GPLv2", "GPLv3",
8
- "Gemfile"]
6
+ spec.files = Dir.glob("{examples,lib,spec,manual}/**/**/*") +
7
+ Dir.glob("data/{encodings,images,pdfs}/*") +
8
+ Dir.glob("data/fonts/{MustRead.html,*.afm}") +
9
+ ["data/shift_jis_text.txt"] +
10
+ ["Rakefile", "prawn.gemspec", "Gemfile",
11
+ "COPYING", "LICENSE", "GPLv2", "GPLv3",
12
+ ".yardopts"]
9
13
  spec.require_path = "lib"
10
- spec.required_ruby_version = '>= 1.8.7'
14
+ spec.required_ruby_version = '>= 1.9.3'
11
15
  spec.required_rubygems_version = ">= 1.3.6"
12
16
 
13
17
  spec.test_files = Dir[ "spec/*_spec.rb" ]
14
- spec.extra_rdoc_files = %w{README.md LICENSE COPYING GPLv2 GPLv3}
15
- spec.rdoc_options << '--title' << 'Prawn Documentation' <<
16
- '--main' << 'README.md' << '-q'
17
18
  spec.authors = ["Gregory Brown","Brad Ediger","Daniel Nelson","Jonathan Greenberg","James Healy"]
18
19
  spec.email = ["gregory.t.brown@gmail.com","brad@bradediger.com","dnelson@bluejade.com","greenberg@entryway.net","jimmy@deefa.com"]
19
20
  spec.rubyforge_project = "prawn"
20
- spec.add_dependency('pdf-reader', '>=0.9.0', '<2.0')
21
- spec.add_dependency('ttfunk', '~>1.0.3')
22
- spec.add_dependency('ruby-rc4')
23
- spec.add_dependency('afm')
24
- spec.add_development_dependency('pdf-inspector', '~> 1.0.1')
21
+ spec.licenses = ['RUBY', 'GPL-2', 'GPL-3']
22
+
23
+ spec.add_dependency('ttfunk', '~> 1.1.1')
24
+ spec.add_dependency('pdf-core', "~> 0.2.2")
25
+
26
+ spec.add_development_dependency('pdf-inspector', '~> 1.1.0')
25
27
  spec.add_development_dependency('coderay', '~> 1.0.7')
26
- spec.add_development_dependency('rdoc')
28
+ spec.add_development_dependency('yard')
29
+ spec.add_development_dependency('rspec')
30
+ spec.add_development_dependency('mocha')
31
+ spec.add_development_dependency('rake')
32
+ spec.add_development_dependency('simplecov')
33
+ spec.add_development_dependency('pdf-reader', '~>1.2')
34
+
27
35
  spec.homepage = "http://prawn.majesticseacreature.com"
28
36
  spec.description = <<END_DESC
29
37
  Prawn is a fast, tiny, and nimble PDF generator for Ruby
@@ -0,0 +1,23 @@
1
+ require_relative "../../lib/prawn"
2
+
3
+ images = [
4
+ ["Type 0", "#{Prawn::BASEDIR}/data/images/web-links.png"],
5
+ ["Type 2", "#{Prawn::BASEDIR}/data/images/ruport.png"],
6
+ ["Type 3", "#{Prawn::BASEDIR}/data/images/indexed_color.png"],
7
+ ["Type 4", "#{Prawn::BASEDIR}/data/images/page_white_text.png"],
8
+ ["Type 6", "#{Prawn::BASEDIR}/data/images/dice.png"],
9
+ ]
10
+
11
+ Prawn::Document.generate("png_types.pdf", :page_size => "A5") do
12
+ images.each do |header, file|
13
+ start_new_page unless header.include?("0")
14
+
15
+ fill_color "FF0000"
16
+
17
+ fill_rectangle bounds.top_left, bounds.width, bounds.height
18
+ text header
19
+
20
+ image file, :at => [50,450]
21
+ end
22
+ end
23
+
@@ -1,35 +1,19 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
4
-
5
- class PageAnnotations
6
- attr_reader :pages
7
-
8
- def self.parse(document)
9
- receiver = new
10
- PDF::Reader.string(document.render, receiver)
11
- return receiver
12
- end
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
13
4
 
14
- def initialize
15
- @pages = []
16
- end
17
5
 
18
- def begin_page(params)
19
- @pages << params
20
- end
21
- end
6
+ describe "When creating annotations" do
22
7
 
23
- describe "When creating annotations" do
24
-
25
8
  before(:each) { create_pdf }
26
-
27
- it "should append annotation to current page" do
9
+
10
+ it "should append annotation to current page" do
28
11
  @pdf.start_new_page
29
12
  @pdf.annotate(:Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
30
- obj = PageAnnotations.parse(@pdf)
31
- obj.pages[0][:Annots].nil?.should == true
32
- obj.pages[1][:Annots].length.should == 1
13
+ PDF::Reader.open(StringIO.new(@pdf.render)) do |pdf|
14
+ pdf.page(1).attributes[:Annots].should be_nil
15
+ pdf.page(2).attributes[:Annots].size.should == 1
16
+ end
33
17
  end
34
18
 
35
19
  it "should force :Type to be :Annot" do
@@ -42,14 +26,14 @@ describe "When creating annotations" do
42
26
  end
43
27
 
44
28
  describe "When creating text annotations" do
45
-
29
+
46
30
  before(:each) do
47
31
  @rect = [0,0,10,10]
48
32
  @content = "Hello, world!"
49
33
  create_pdf
50
34
  end
51
-
52
- it "should build appropriate annotation" do
35
+
36
+ it "should build appropriate annotation" do
53
37
  opts = @pdf.text_annotation(@rect, @content)
54
38
  opts[:Type].should == :Annot
55
39
  opts[:Subtype].should == :Text
@@ -57,7 +41,7 @@ describe "When creating text annotations" do
57
41
  opts[:Contents].should == @content
58
42
  end
59
43
 
60
- it "should merge extra options" do
44
+ it "should merge extra options" do
61
45
  opts = @pdf.text_annotation(@rect, @content, :Open => true, :Subtype => :Bogus)
62
46
  opts[:Subtype].should == :Text
63
47
  opts[:Open].should == true
@@ -66,14 +50,14 @@ describe "When creating text annotations" do
66
50
  end
67
51
 
68
52
  describe "When creating link annotations" do
69
-
53
+
70
54
  before(:each) do
71
55
  @rect = [0,0,10,10]
72
56
  @dest = "home"
73
57
  create_pdf
74
58
  end
75
-
76
- it "should build appropriate annotation" do
59
+
60
+ it "should build appropriate annotation" do
77
61
  opts = @pdf.link_annotation(@rect, :Dest => @dest)
78
62
  opts[:Type].should == :Annot
79
63
  opts[:Subtype].should == :Link
@@ -81,7 +65,7 @@ describe "When creating link annotations" do
81
65
  opts[:Dest].should == @dest
82
66
  end
83
67
 
84
- it "should merge extra options" do
68
+ it "should merge extra options" do
85
69
  opts = @pdf.link_annotation(@rect, :Dest => @dest, :Subtype => :Bogus)
86
70
  opts[:Subtype].should == :Link
87
71
  opts[:Dest].should == @dest