prawn 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/GPLv2 +20 -21
  5. data/Gemfile +2 -0
  6. data/Rakefile +10 -3
  7. data/lib/prawn.rb +9 -3
  8. data/lib/prawn/document.rb +40 -18
  9. data/lib/prawn/document/bounding_box.rb +9 -4
  10. data/lib/prawn/document/column_box.rb +2 -0
  11. data/lib/prawn/document/internals.rb +6 -4
  12. data/lib/prawn/document/span.rb +2 -0
  13. data/lib/prawn/encoding.rb +4 -1
  14. data/lib/prawn/errors.rb +2 -0
  15. data/lib/prawn/font.rb +34 -17
  16. data/lib/prawn/font_metric_cache.rb +8 -3
  17. data/lib/prawn/{font → fonts}/afm.rb +14 -7
  18. data/lib/prawn/{font → fonts}/dfont.rb +3 -1
  19. data/lib/prawn/fonts/otf.rb +11 -0
  20. data/lib/prawn/{font → fonts}/ttc.rb +3 -1
  21. data/lib/prawn/{font → fonts}/ttf.rb +23 -12
  22. data/lib/prawn/graphics.rb +24 -26
  23. data/lib/prawn/graphics/blend_mode.rb +2 -0
  24. data/lib/prawn/graphics/cap_style.rb +2 -0
  25. data/lib/prawn/graphics/color.rb +8 -3
  26. data/lib/prawn/graphics/dash.rb +3 -1
  27. data/lib/prawn/graphics/join_style.rb +2 -0
  28. data/lib/prawn/graphics/patterns.rb +7 -2
  29. data/lib/prawn/graphics/transformation.rb +5 -1
  30. data/lib/prawn/graphics/transparency.rb +2 -0
  31. data/lib/prawn/grid.rb +39 -38
  32. data/lib/prawn/image_handler.rb +2 -0
  33. data/lib/prawn/images.rb +21 -19
  34. data/lib/prawn/images/image.rb +2 -0
  35. data/lib/prawn/images/jpg.rb +2 -0
  36. data/lib/prawn/images/png.rb +9 -9
  37. data/lib/prawn/measurement_extensions.rb +2 -0
  38. data/lib/prawn/measurements.rb +5 -0
  39. data/lib/prawn/outline.rb +2 -0
  40. data/lib/prawn/repeater.rb +2 -0
  41. data/lib/prawn/security.rb +26 -24
  42. data/lib/prawn/security/arcfour.rb +2 -0
  43. data/lib/prawn/soft_mask.rb +3 -1
  44. data/lib/prawn/stamp.rb +4 -1
  45. data/lib/prawn/text.rb +14 -12
  46. data/lib/prawn/text/box.rb +3 -1
  47. data/lib/prawn/text/formatted.rb +2 -0
  48. data/lib/prawn/text/formatted/arranger.rb +12 -12
  49. data/lib/prawn/text/formatted/box.rb +23 -13
  50. data/lib/prawn/text/formatted/fragment.rb +2 -0
  51. data/lib/prawn/text/formatted/line_wrap.rb +10 -8
  52. data/lib/prawn/text/formatted/parser.rb +8 -10
  53. data/lib/prawn/text/formatted/wrap.rb +4 -2
  54. data/lib/prawn/transformation_stack.rb +5 -2
  55. data/lib/prawn/utilities.rb +2 -2
  56. data/lib/prawn/version.rb +3 -1
  57. data/lib/prawn/view.rb +15 -7
  58. data/manual/basic_concepts/adding_pages.rb +2 -0
  59. data/manual/basic_concepts/basic_concepts.rb +4 -2
  60. data/manual/basic_concepts/creation.rb +2 -0
  61. data/manual/basic_concepts/cursor.rb +2 -0
  62. data/manual/basic_concepts/measurement.rb +3 -1
  63. data/manual/basic_concepts/origin.rb +2 -0
  64. data/manual/basic_concepts/other_cursor_helpers.rb +2 -0
  65. data/manual/basic_concepts/view.rb +2 -0
  66. data/manual/bounding_box/bounding_box.rb +4 -2
  67. data/manual/bounding_box/bounds.rb +6 -4
  68. data/manual/bounding_box/canvas.rb +2 -0
  69. data/manual/bounding_box/creation.rb +2 -0
  70. data/manual/bounding_box/indentation.rb +2 -0
  71. data/manual/bounding_box/nesting.rb +2 -0
  72. data/manual/bounding_box/russian_boxes.rb +6 -4
  73. data/manual/bounding_box/stretchy.rb +2 -0
  74. data/manual/contents.rb +2 -0
  75. data/manual/cover.rb +10 -7
  76. data/manual/document_and_page_options/background.rb +2 -0
  77. data/manual/document_and_page_options/document_and_page_options.rb +4 -2
  78. data/manual/document_and_page_options/metadata.rb +2 -0
  79. data/manual/document_and_page_options/page_margins.rb +2 -0
  80. data/manual/document_and_page_options/page_size.rb +2 -0
  81. data/manual/document_and_page_options/print_scaling.rb +2 -0
  82. data/manual/example_helper.rb +5 -2
  83. data/manual/graphics/blend_mode.rb +6 -4
  84. data/manual/graphics/circle_and_ellipse.rb +2 -0
  85. data/manual/graphics/color.rb +2 -0
  86. data/manual/graphics/common_lines.rb +2 -0
  87. data/manual/graphics/fill_and_stroke.rb +2 -0
  88. data/manual/graphics/fill_rules.rb +2 -0
  89. data/manual/graphics/gradients.rb +2 -0
  90. data/manual/graphics/graphics.rb +4 -2
  91. data/manual/graphics/helper.rb +2 -0
  92. data/manual/graphics/line_width.rb +3 -0
  93. data/manual/graphics/lines_and_curves.rb +2 -0
  94. data/manual/graphics/polygon.rb +2 -0
  95. data/manual/graphics/rectangle.rb +2 -0
  96. data/manual/graphics/rotate.rb +2 -0
  97. data/manual/graphics/scale.rb +2 -0
  98. data/manual/graphics/soft_masks.rb +2 -0
  99. data/manual/graphics/stroke_cap.rb +3 -1
  100. data/manual/graphics/stroke_dash.rb +2 -0
  101. data/manual/graphics/stroke_join.rb +3 -1
  102. data/manual/graphics/translate.rb +2 -0
  103. data/manual/graphics/transparency.rb +2 -0
  104. data/manual/how_to_read_this_manual.rb +2 -0
  105. data/manual/images/absolute_position.rb +2 -0
  106. data/manual/images/fit.rb +2 -0
  107. data/manual/images/horizontal.rb +3 -1
  108. data/manual/images/images.rb +4 -2
  109. data/manual/images/plain_image.rb +2 -0
  110. data/manual/images/scale.rb +2 -0
  111. data/manual/images/vertical.rb +3 -1
  112. data/manual/images/width_and_height.rb +2 -0
  113. data/manual/layout/boxes.rb +2 -0
  114. data/manual/layout/content.rb +2 -0
  115. data/manual/layout/layout.rb +4 -2
  116. data/manual/layout/simple_grid.rb +2 -0
  117. data/manual/outline/add_subsection_to.rb +2 -0
  118. data/manual/outline/insert_section_after.rb +2 -0
  119. data/manual/outline/outline.rb +4 -2
  120. data/manual/outline/sections_and_pages.rb +2 -0
  121. data/manual/repeatable_content/alternate_page_numbering.rb +2 -0
  122. data/manual/repeatable_content/page_numbering.rb +2 -0
  123. data/manual/repeatable_content/repeatable_content.rb +4 -2
  124. data/manual/repeatable_content/repeater.rb +2 -0
  125. data/manual/repeatable_content/stamp.rb +2 -0
  126. data/manual/security/encryption.rb +2 -0
  127. data/manual/security/permissions.rb +2 -0
  128. data/manual/security/security.rb +4 -2
  129. data/manual/table.rb +2 -0
  130. data/manual/text/alignment.rb +2 -0
  131. data/manual/text/color.rb +2 -0
  132. data/manual/text/column_box.rb +4 -2
  133. data/manual/text/fallback_fonts.rb +4 -2
  134. data/manual/text/font.rb +2 -0
  135. data/manual/text/font_size.rb +2 -0
  136. data/manual/text/font_style.rb +4 -2
  137. data/manual/text/formatted_callbacks.rb +2 -0
  138. data/manual/text/formatted_text.rb +3 -1
  139. data/manual/text/free_flowing_text.rb +2 -0
  140. data/manual/text/inline.rb +2 -0
  141. data/manual/text/kerning_and_character_spacing.rb +2 -0
  142. data/manual/text/leading.rb +2 -0
  143. data/manual/text/line_wrapping.rb +4 -1
  144. data/manual/text/paragraph_indentation.rb +2 -0
  145. data/manual/text/positioned_text.rb +2 -0
  146. data/manual/text/registering_families.rb +4 -2
  147. data/manual/text/rendering_and_color.rb +2 -0
  148. data/manual/text/right_to_left_text.rb +2 -0
  149. data/manual/text/rotation.rb +3 -1
  150. data/manual/text/single_usage.rb +2 -0
  151. data/manual/text/text.rb +4 -3
  152. data/manual/text/text_box_excess.rb +2 -0
  153. data/manual/text/text_box_extensions.rb +2 -0
  154. data/manual/text/text_box_overflow.rb +3 -1
  155. data/manual/text/utf8.rb +3 -1
  156. data/manual/text/win_ansi_charset.rb +6 -3
  157. data/prawn.gemspec +14 -11
  158. data/spec/extensions/encoding_helpers.rb +4 -2
  159. data/spec/prawn/document/bounding_box_spec.rb +8 -8
  160. data/spec/prawn/document/column_box_spec.rb +2 -0
  161. data/spec/prawn/document/security_spec.rb +12 -9
  162. data/spec/prawn/document_annotations_spec.rb +2 -0
  163. data/spec/prawn/document_destinations_spec.rb +2 -0
  164. data/spec/prawn/document_grid_spec.rb +3 -0
  165. data/spec/prawn/document_reference_spec.rb +2 -0
  166. data/spec/prawn/document_span_spec.rb +2 -0
  167. data/spec/prawn/document_spec.rb +59 -14
  168. data/spec/prawn/font_metric_cache_spec.rb +2 -0
  169. data/spec/prawn/font_spec.rb +45 -16
  170. data/spec/prawn/graphics/blend_mode_spec.rb +4 -2
  171. data/spec/prawn/graphics/transparency_spec.rb +2 -0
  172. data/spec/prawn/graphics_spec.rb +40 -20
  173. data/spec/prawn/graphics_stroke_styles_spec.rb +2 -0
  174. data/spec/prawn/image_handler_spec.rb +2 -0
  175. data/spec/prawn/images/jpg_spec.rb +2 -0
  176. data/spec/prawn/images/png_spec.rb +2 -0
  177. data/spec/prawn/images_spec.rb +56 -2
  178. data/spec/prawn/measurements_extensions_spec.rb +2 -0
  179. data/spec/prawn/outline_spec.rb +6 -2
  180. data/spec/prawn/repeater_spec.rb +6 -4
  181. data/spec/prawn/soft_mask_spec.rb +2 -0
  182. data/spec/prawn/stamp_spec.rb +11 -7
  183. data/spec/prawn/text/box_spec.rb +26 -27
  184. data/spec/prawn/text/formatted/arranger_spec.rb +30 -28
  185. data/spec/prawn/text/formatted/box_spec.rb +78 -57
  186. data/spec/prawn/text/formatted/fragment_spec.rb +10 -8
  187. data/spec/prawn/text/formatted/line_wrap_spec.rb +8 -5
  188. data/spec/prawn/text/formatted/parser_spec.rb +32 -2
  189. data/spec/prawn/text_draw_text_spec.rb +5 -3
  190. data/spec/prawn/text_rendering_mode_spec.rb +7 -1
  191. data/spec/prawn/text_spacing_spec.rb +6 -4
  192. data/spec/prawn/text_spec.rb +9 -7
  193. data/spec/prawn/text_with_inline_formatting_spec.rb +3 -1
  194. data/spec/prawn/transformation_stack_spec.rb +2 -0
  195. data/spec/prawn/view_spec.rb +18 -0
  196. data/spec/{manual_spec.rb → prawn_manual_spec.rb} +6 -4
  197. data/spec/spec_helper.rb +9 -10
  198. metadata +86 -73
  199. metadata.gz.sig +4 -2
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # utilities.rb : General-purpose utility classes which don't fit anywhere else
2
4
  #
3
5
  # Copyright August 2012, Alex Dowad. All Rights Reserved.
4
6
  #
5
7
  # This is free software. Please see the LICENSE and COPYING files for details.
6
8
 
7
- require 'thread'
8
-
9
9
  module Prawn
10
10
  # Throughout the Prawn codebase, repeated calculations which can benefit from
11
11
  # caching are made.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Prawn
2
- VERSION = '2.2.2'.freeze
4
+ VERSION = '2.3.0'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # prawn/view.rb : Implements a mixin for Prawn's DSL
2
4
  #
3
5
  # This is free software. Please see the LICENSE and COPYING files for details.
@@ -9,6 +11,12 @@ module Prawn
9
11
  # class Greeter
10
12
  # include Prawn::View
11
13
  #
14
+ # # Optional override: allows you to set document options or even use
15
+ # # a custom document class
16
+ # def document
17
+ # @document ||= Prawn::Document.new(page_size: 'A4')
18
+ # end
19
+ #
12
20
  # def initialize(name)
13
21
  # @name = name
14
22
  # end
@@ -61,14 +69,14 @@ module Prawn
61
69
 
62
70
  # Delegates all unhandled calls to object returned by +document+ method.
63
71
  # (which is an instance of Prawn::Document by default)
64
- def method_missing(m, *a, &b)
65
- return super unless document.respond_to?(m)
72
+ def method_missing(method_name, *arguments, &block)
73
+ return super unless document.respond_to?(method_name)
66
74
 
67
- document.send(m, *a, &b)
75
+ document.send(method_name, *arguments, &block)
68
76
  end
69
77
 
70
- def respond_to_missing?
71
- document.respond_to?(m)
78
+ def respond_to_missing?(method_name, _include_all = false)
79
+ document.respond_to?(method_name)
72
80
  end
73
81
 
74
82
  # Syntactic sugar that uses +instance_eval+ under the hood to provide
@@ -79,8 +87,8 @@ module Prawn
79
87
  # say_goodbye
80
88
  # end
81
89
  #
82
- def update(&b)
83
- instance_eval(&b)
90
+ def update(&block)
91
+ instance_eval(&block)
84
92
  end
85
93
 
86
94
  # Syntatic sugar that calls +document.render_file+ under the hood.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A PDF document is a collection of pages. When we create a new document be it
2
4
  # with <code>Document.new</code> or on a <code>Document.generate</code> block
3
5
  # one initial page is created for us.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Examples for Prawn basic concepts.
2
4
  #
3
5
 
@@ -15,7 +17,7 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
15
17
  p.example 'view', eval_source: false, full_source: true
16
18
 
17
19
  p.intro do
18
- prose <<-END
20
+ prose <<-TEXT
19
21
  This chapter covers the minimum amount of functionality you'll need to
20
22
  start using Prawn.
21
23
 
@@ -24,7 +26,7 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
24
26
  Basics section of the Graphics, Bounding Box and Text sections.
25
27
 
26
28
  The examples show:
27
- END
29
+ TEXT
28
30
 
29
31
  list(
30
32
  'How to create new pdf documents in every possible way',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # There are three ways to create a PDF Document in Prawn: creating a new
2
4
  # <code>Prawn::Document</code> instance, or using the
3
5
  # <code>Prawn::Document.generate</code> method with and without block arguments.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # We normally write our documents from top to bottom and it is no different with
2
4
  # Prawn. Even if the origin is on the bottom left corner we still fill the page
3
5
  # from the top to the bottom. In other words the cursor for inserting content
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The base unit in Prawn is the PDF Point. One PDF Point is equal to 1/72 of
2
4
  # an inch.
3
5
  #
@@ -15,7 +17,7 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf')
15
17
  Prawn::ManualBuilder::Example.generate(filename) do
16
18
  require 'prawn/measurement_extensions'
17
19
 
18
- [:mm, :cm, :dm, :m, :in, :yd, :ft].each do |measurement|
20
+ %i[mm cm dm m in yd ft].each do |measurement|
19
21
  text "1 #{measurement} in PDF Points: #{1.send(measurement)} pt"
20
22
  move_down 5.mm
21
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is the most important concept you need to learn about Prawn:
2
4
  #
3
5
  # PDF documents have the origin <code>[0,0]</code> at the bottom-left corner of
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Another group of helpers for changing the cursor position are the pad methods.
2
4
  # They accept a numeric value and a block. <code>pad</code> will use the numeric
3
5
  # value to move the cursor down both before and after the block content.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The recommended way to extend Prawn's functionality is to include the
2
4
  # <code>Prawn::View</code> mixin in your own class, which will make all
3
5
  # <code>Prawn::Document</code> methods available to your custom objects.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Examples for bounding boxes.
2
4
 
3
5
  require_relative '../example_helper'
@@ -19,13 +21,13 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
19
21
  end
20
22
 
21
23
  p.intro do
22
- prose <<-END
24
+ prose <<-TEXT
23
25
  Bounding boxes are the basic containers for structuring the content
24
26
  flow. Even being low level building blocks sometimes their simplicity is
25
27
  very welcome.
26
28
 
27
29
  The examples show:
28
- END
30
+ TEXT
29
31
 
30
32
  list(
31
33
  'How to create bounding boxes with specific dimensions',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The <code>bounds</code> method returns the current bounding box. This is
2
4
  # useful because the <code>Prawn::BoundingBox</code> exposes some nice boundary
3
5
  # helpers.
@@ -27,10 +29,10 @@ Prawn::ManualBuilder::Example.generate(filename) do
27
29
 
28
30
  move_down 10
29
31
 
30
- text "absolute top: #{format '%.2f', bounds.absolute_top}"
31
- text "absolute bottom: #{format '%.2f', bounds.absolute_bottom}"
32
- text "absolute left: #{format '%.2f', bounds.absolute_left}"
33
- text "absolute right: #{format '%.2f', bounds.absolute_right}"
32
+ text "absolute top: #{bounds.absolute_top.to_f.round(2)}"
33
+ text "absolute bottom: #{bounds.absolute_bottom.to_f.round(2)}"
34
+ text "absolute left: #{bounds.absolute_left.to_f.round(2)}"
35
+ text "absolute right: #{bounds.absolute_right.to_f.round(2)}"
34
36
  end
35
37
 
36
38
  text 'Margin box bounds:'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The origin example already mentions that a new document already comes with
2
4
  # a margin box whose bottom left corner is used as the origin for calculating
3
5
  # coordinates.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # If you've read the basic concepts examples you probably know that the origin
2
4
  # of a page is on the bottom left corner and that the content flows from top to
3
5
  # bottom.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Sometimes you just need to indent a portion of the contents of a bounding box,
2
4
  # and using a nested bounding box is pure overkill. The <code>indent</code>
3
5
  # method is what you might need.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Normally when we provide the top left corner of a bounding box we
2
4
  # express the coordinates relative to the margin box. This is not the
3
5
  # case when we have nested bounding boxes. Once nested the inner bounding box
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This example is mostly just for fun, and shows how nested bounding boxes
2
4
  # can simplify calculations. See the "Bounding Box" section of the manual
3
5
  # for more basic uses.
@@ -6,11 +8,11 @@ require_relative '../example_helper'
6
8
 
7
9
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
8
10
  Prawn::ManualBuilder::Example.generate(filename) do
9
- def combine(a1, a2)
11
+ def combine(horizontal_span, vertical_span)
10
12
  output = []
11
- a1.each do |i1|
12
- a2.each do |i2|
13
- output += [[i1, i2]]
13
+ horizontal_span.each do |x|
14
+ vertical_span.each do |y|
15
+ output += [[x, y]]
14
16
  end
15
17
  end
16
18
  output
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Bounding Boxes accept an optional <code>:height</code> parameter. Unless it
2
4
  # is provided the bounding box will be stretchy. It will expand the height to
3
5
  # fit all content generated inside it.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Generates the Prawn by example manual.
2
4
 
3
5
  require_relative 'example_helper'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Prawn manual how to read this manual page.
2
4
 
3
5
  require_relative 'example_helper'
@@ -20,14 +22,15 @@ Prawn::ManualBuilder::Example.generate(filename) do
20
22
  at: [170, cursor - 160]
21
23
  )
22
24
 
23
- if Dir.exist?("#{Prawn::BASEDIR}/.git")
24
- commit = `git show --pretty=%h`
25
- git_commit = "git commit: #{commit.lines.first}"
26
- else
27
- git_commit = ''
28
- end
29
-
30
25
  unless ENV['CI']
26
+ git_commit =
27
+ if Dir.exist?("#{Prawn::BASEDIR}/.git")
28
+ commit = `git show --pretty=%h`
29
+ "git commit: #{commit.lines.first}"
30
+ else
31
+ ''
32
+ end
33
+
31
34
  formatted_text_box(
32
35
  [{
33
36
  text: "Last Update: #{Time.now.strftime('%Y-%m-%d')}\n" \
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Pass an image path to the <code>:background</code> option and it will be used
2
4
  # as the background for all pages.
3
5
  # This option can only be used on document creation.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Examples for stamps and repeaters.
2
4
 
3
5
  require_relative '../example_helper'
@@ -12,14 +14,14 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
12
14
  p.example 'print_scaling', eval_source: false, full_source: true
13
15
 
14
16
  p.intro do
15
- prose <<-END
17
+ prose <<-TEXT
16
18
  So far we've already seen how to create new documents and start new
17
19
  pages. This chapter expands on the previous examples by showing other
18
20
  options avialable. Some of the options are only available when creating
19
21
  new documents.
20
22
 
21
23
  The examples show:
22
- END
24
+ TEXT
23
25
 
24
26
  list(
25
27
  'How to configure page size',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # To set the document metadata just pass a hash to the <code>:info</code>
2
4
  # option when creating new documents.
3
5
  # The keys in the example below are arbitrary, so you may add whatever keys you
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The default margin for pages is 0.5 inch but you can change that with the
2
4
  # <code>:margin</code> option or if you'd like to have different margins you
3
5
  # can use the <code>:left_margin</code>, <code>:right_margin</code>,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Prawn comes with support for most of the common page sizes so you'll only need
2
4
  # to provide specific values if your intended format is not supported. To see a
3
5
  # list with all supported sizes take a look at PDF::Core::PageGeometry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # (Optional; PDF 1.6) The page scaling option to be selected when a print dialog
2
4
  # is displayed for this document. Valid values are <code>None</code>, which
3
5
  # indicates that the print dialog should reflect no page scaling, and
@@ -1,5 +1,8 @@
1
- require_relative '../lib/prawn'
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.join(__dir__, '../lib')
4
+ require 'prawn'
2
5
  require 'prawn/manual_builder'
3
6
 
4
7
  Prawn::ManualBuilder.manual_dir = File.dirname(__FILE__)
5
- Prawn::Font::AFM.hide_m17n_warning = true
8
+ Prawn::Fonts::AFM.hide_m17n_warning = true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Blend modes can be used to change the way two layers (images, graphics,
2
4
  # text, etc.) are blended together. The <code>blend_mode</code> method
3
5
  # accepts a single blend mode or an array of blend modes. PDF viewers should
@@ -19,10 +21,10 @@ Prawn::ManualBuilder::Example.generate(filename) do
19
21
  # https://commons.wikimedia.org/wiki/File:Blend_modes_1.-top-layer.jpg#/media/File:Blend_modes_1.-top-layer.jpg
20
22
  top_layer = "#{Prawn::DATADIR}/images/blend_modes_top_layer.jpg"
21
23
 
22
- blend_modes = [
23
- :Normal, :Multiply, :Screen, :Overlay, :Darken, :Lighten, :ColorDodge,
24
- :ColorBurn, :HardLight, :SoftLight, :Difference, :Exclusion, :Hue,
25
- :Saturation, :Color, :Luminosity
24
+ blend_modes = %i[
25
+ Normal Multiply Screen Overlay Darken Lighten ColorDodge
26
+ ColorBurn HardLight SoftLight Difference Exclusion Hue
27
+ Saturation Color Luminosity
26
28
  ]
27
29
  blend_modes.each_with_index do |blend_mode, index|
28
30
  x = index % 4 * 135
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # To define a <code>circle</code> all you need is the center point and the
2
4
  # radius.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # We can change the stroke and fill colors providing an HTML rgb 6 digit color
2
4
  # code string ("AB1234") or 4 values for CMYK.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Prawn provides helpers for drawing some commonly used lines:
2
4
  #
3
5
  # <code>vertical_line</code> and <code>horizontal_line</code> do just what their
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # There are two drawing primitives in Prawn: <code>fill</code> and
2
4
  # <code>stroke</code>.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Prawn's fill operators (<code>fill</code> and <code>fill_and_stroke</code>
2
4
  # both accept a <code>:fill_rule</code> option. These rules determine which
3
5
  # parts of the page are counted as "inside" vs. "outside" the path. There are
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Note that because of the way PDF renders radial gradients in order to get
2
4
  # solid fill your start circle must be fully inside your end circle.
3
5
  # Otherwise you will get triangle fill like illustrated in the example below.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Examples for the Graphics package.
2
4
 
3
5
  require_relative '../example_helper'
@@ -38,7 +40,7 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
38
40
  end
39
41
 
40
42
  p.intro do
41
- prose <<-END
43
+ prose <<-TEXT
42
44
  Here we show all the drawing methods provided by Prawn. Use them to draw
43
45
  the most beautiful imaginable things.
44
46
 
@@ -48,7 +50,7 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
48
50
  least read the basic examples.
49
51
 
50
52
  The examples show:
51
- END
53
+ TEXT
52
54
 
53
55
  list(
54
56
  'All the possible ways that you can fill or stroke shapes on a page',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # To produce this manual we use the <code>stroke_axis</code> helper method
2
4
  # within the examples.
3
5
  #