prawn 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/GPLv2 +20 -21
- data/Gemfile +2 -0
- data/Rakefile +10 -3
- data/lib/prawn.rb +9 -3
- data/lib/prawn/document.rb +40 -18
- data/lib/prawn/document/bounding_box.rb +9 -4
- data/lib/prawn/document/column_box.rb +2 -0
- data/lib/prawn/document/internals.rb +6 -4
- data/lib/prawn/document/span.rb +2 -0
- data/lib/prawn/encoding.rb +4 -1
- data/lib/prawn/errors.rb +2 -0
- data/lib/prawn/font.rb +34 -17
- data/lib/prawn/font_metric_cache.rb +8 -3
- data/lib/prawn/{font → fonts}/afm.rb +14 -7
- data/lib/prawn/{font → fonts}/dfont.rb +3 -1
- data/lib/prawn/fonts/otf.rb +11 -0
- data/lib/prawn/{font → fonts}/ttc.rb +3 -1
- data/lib/prawn/{font → fonts}/ttf.rb +23 -12
- data/lib/prawn/graphics.rb +24 -26
- data/lib/prawn/graphics/blend_mode.rb +2 -0
- data/lib/prawn/graphics/cap_style.rb +2 -0
- data/lib/prawn/graphics/color.rb +8 -3
- data/lib/prawn/graphics/dash.rb +3 -1
- data/lib/prawn/graphics/join_style.rb +2 -0
- data/lib/prawn/graphics/patterns.rb +7 -2
- data/lib/prawn/graphics/transformation.rb +5 -1
- data/lib/prawn/graphics/transparency.rb +2 -0
- data/lib/prawn/grid.rb +39 -38
- data/lib/prawn/image_handler.rb +2 -0
- data/lib/prawn/images.rb +21 -19
- data/lib/prawn/images/image.rb +2 -0
- data/lib/prawn/images/jpg.rb +2 -0
- data/lib/prawn/images/png.rb +9 -9
- data/lib/prawn/measurement_extensions.rb +2 -0
- data/lib/prawn/measurements.rb +5 -0
- data/lib/prawn/outline.rb +2 -0
- data/lib/prawn/repeater.rb +2 -0
- data/lib/prawn/security.rb +26 -24
- data/lib/prawn/security/arcfour.rb +2 -0
- data/lib/prawn/soft_mask.rb +3 -1
- data/lib/prawn/stamp.rb +4 -1
- data/lib/prawn/text.rb +14 -12
- data/lib/prawn/text/box.rb +3 -1
- data/lib/prawn/text/formatted.rb +2 -0
- data/lib/prawn/text/formatted/arranger.rb +12 -12
- data/lib/prawn/text/formatted/box.rb +23 -13
- data/lib/prawn/text/formatted/fragment.rb +2 -0
- data/lib/prawn/text/formatted/line_wrap.rb +10 -8
- data/lib/prawn/text/formatted/parser.rb +8 -10
- data/lib/prawn/text/formatted/wrap.rb +4 -2
- data/lib/prawn/transformation_stack.rb +5 -2
- data/lib/prawn/utilities.rb +2 -2
- data/lib/prawn/version.rb +3 -1
- data/lib/prawn/view.rb +15 -7
- data/manual/basic_concepts/adding_pages.rb +2 -0
- data/manual/basic_concepts/basic_concepts.rb +4 -2
- data/manual/basic_concepts/creation.rb +2 -0
- data/manual/basic_concepts/cursor.rb +2 -0
- data/manual/basic_concepts/measurement.rb +3 -1
- data/manual/basic_concepts/origin.rb +2 -0
- data/manual/basic_concepts/other_cursor_helpers.rb +2 -0
- data/manual/basic_concepts/view.rb +2 -0
- data/manual/bounding_box/bounding_box.rb +4 -2
- data/manual/bounding_box/bounds.rb +6 -4
- data/manual/bounding_box/canvas.rb +2 -0
- data/manual/bounding_box/creation.rb +2 -0
- data/manual/bounding_box/indentation.rb +2 -0
- data/manual/bounding_box/nesting.rb +2 -0
- data/manual/bounding_box/russian_boxes.rb +6 -4
- data/manual/bounding_box/stretchy.rb +2 -0
- data/manual/contents.rb +2 -0
- data/manual/cover.rb +10 -7
- data/manual/document_and_page_options/background.rb +2 -0
- data/manual/document_and_page_options/document_and_page_options.rb +4 -2
- data/manual/document_and_page_options/metadata.rb +2 -0
- data/manual/document_and_page_options/page_margins.rb +2 -0
- data/manual/document_and_page_options/page_size.rb +2 -0
- data/manual/document_and_page_options/print_scaling.rb +2 -0
- data/manual/example_helper.rb +5 -2
- data/manual/graphics/blend_mode.rb +6 -4
- data/manual/graphics/circle_and_ellipse.rb +2 -0
- data/manual/graphics/color.rb +2 -0
- data/manual/graphics/common_lines.rb +2 -0
- data/manual/graphics/fill_and_stroke.rb +2 -0
- data/manual/graphics/fill_rules.rb +2 -0
- data/manual/graphics/gradients.rb +2 -0
- data/manual/graphics/graphics.rb +4 -2
- data/manual/graphics/helper.rb +2 -0
- data/manual/graphics/line_width.rb +3 -0
- data/manual/graphics/lines_and_curves.rb +2 -0
- data/manual/graphics/polygon.rb +2 -0
- data/manual/graphics/rectangle.rb +2 -0
- data/manual/graphics/rotate.rb +2 -0
- data/manual/graphics/scale.rb +2 -0
- data/manual/graphics/soft_masks.rb +2 -0
- data/manual/graphics/stroke_cap.rb +3 -1
- data/manual/graphics/stroke_dash.rb +2 -0
- data/manual/graphics/stroke_join.rb +3 -1
- data/manual/graphics/translate.rb +2 -0
- data/manual/graphics/transparency.rb +2 -0
- data/manual/how_to_read_this_manual.rb +2 -0
- data/manual/images/absolute_position.rb +2 -0
- data/manual/images/fit.rb +2 -0
- data/manual/images/horizontal.rb +3 -1
- data/manual/images/images.rb +4 -2
- data/manual/images/plain_image.rb +2 -0
- data/manual/images/scale.rb +2 -0
- data/manual/images/vertical.rb +3 -1
- data/manual/images/width_and_height.rb +2 -0
- data/manual/layout/boxes.rb +2 -0
- data/manual/layout/content.rb +2 -0
- data/manual/layout/layout.rb +4 -2
- data/manual/layout/simple_grid.rb +2 -0
- data/manual/outline/add_subsection_to.rb +2 -0
- data/manual/outline/insert_section_after.rb +2 -0
- data/manual/outline/outline.rb +4 -2
- data/manual/outline/sections_and_pages.rb +2 -0
- data/manual/repeatable_content/alternate_page_numbering.rb +2 -0
- data/manual/repeatable_content/page_numbering.rb +2 -0
- data/manual/repeatable_content/repeatable_content.rb +4 -2
- data/manual/repeatable_content/repeater.rb +2 -0
- data/manual/repeatable_content/stamp.rb +2 -0
- data/manual/security/encryption.rb +2 -0
- data/manual/security/permissions.rb +2 -0
- data/manual/security/security.rb +4 -2
- data/manual/table.rb +2 -0
- data/manual/text/alignment.rb +2 -0
- data/manual/text/color.rb +2 -0
- data/manual/text/column_box.rb +4 -2
- data/manual/text/fallback_fonts.rb +4 -2
- data/manual/text/font.rb +2 -0
- data/manual/text/font_size.rb +2 -0
- data/manual/text/font_style.rb +4 -2
- data/manual/text/formatted_callbacks.rb +2 -0
- data/manual/text/formatted_text.rb +3 -1
- data/manual/text/free_flowing_text.rb +2 -0
- data/manual/text/inline.rb +2 -0
- data/manual/text/kerning_and_character_spacing.rb +2 -0
- data/manual/text/leading.rb +2 -0
- data/manual/text/line_wrapping.rb +4 -1
- data/manual/text/paragraph_indentation.rb +2 -0
- data/manual/text/positioned_text.rb +2 -0
- data/manual/text/registering_families.rb +4 -2
- data/manual/text/rendering_and_color.rb +2 -0
- data/manual/text/right_to_left_text.rb +2 -0
- data/manual/text/rotation.rb +3 -1
- data/manual/text/single_usage.rb +2 -0
- data/manual/text/text.rb +4 -3
- data/manual/text/text_box_excess.rb +2 -0
- data/manual/text/text_box_extensions.rb +2 -0
- data/manual/text/text_box_overflow.rb +3 -1
- data/manual/text/utf8.rb +3 -1
- data/manual/text/win_ansi_charset.rb +6 -3
- data/prawn.gemspec +14 -11
- data/spec/extensions/encoding_helpers.rb +4 -2
- data/spec/prawn/document/bounding_box_spec.rb +8 -8
- data/spec/prawn/document/column_box_spec.rb +2 -0
- data/spec/prawn/document/security_spec.rb +12 -9
- data/spec/prawn/document_annotations_spec.rb +2 -0
- data/spec/prawn/document_destinations_spec.rb +2 -0
- data/spec/prawn/document_grid_spec.rb +3 -0
- data/spec/prawn/document_reference_spec.rb +2 -0
- data/spec/prawn/document_span_spec.rb +2 -0
- data/spec/prawn/document_spec.rb +59 -14
- data/spec/prawn/font_metric_cache_spec.rb +2 -0
- data/spec/prawn/font_spec.rb +45 -16
- data/spec/prawn/graphics/blend_mode_spec.rb +4 -2
- data/spec/prawn/graphics/transparency_spec.rb +2 -0
- data/spec/prawn/graphics_spec.rb +40 -20
- data/spec/prawn/graphics_stroke_styles_spec.rb +2 -0
- data/spec/prawn/image_handler_spec.rb +2 -0
- data/spec/prawn/images/jpg_spec.rb +2 -0
- data/spec/prawn/images/png_spec.rb +2 -0
- data/spec/prawn/images_spec.rb +56 -2
- data/spec/prawn/measurements_extensions_spec.rb +2 -0
- data/spec/prawn/outline_spec.rb +6 -2
- data/spec/prawn/repeater_spec.rb +6 -4
- data/spec/prawn/soft_mask_spec.rb +2 -0
- data/spec/prawn/stamp_spec.rb +11 -7
- data/spec/prawn/text/box_spec.rb +26 -27
- data/spec/prawn/text/formatted/arranger_spec.rb +30 -28
- data/spec/prawn/text/formatted/box_spec.rb +78 -57
- data/spec/prawn/text/formatted/fragment_spec.rb +10 -8
- data/spec/prawn/text/formatted/line_wrap_spec.rb +8 -5
- data/spec/prawn/text/formatted/parser_spec.rb +32 -2
- data/spec/prawn/text_draw_text_spec.rb +5 -3
- data/spec/prawn/text_rendering_mode_spec.rb +7 -1
- data/spec/prawn/text_spacing_spec.rb +6 -4
- data/spec/prawn/text_spec.rb +9 -7
- data/spec/prawn/text_with_inline_formatting_spec.rb +3 -1
- data/spec/prawn/transformation_stack_spec.rb +2 -0
- data/spec/prawn/view_spec.rb +18 -0
- data/spec/{manual_spec.rb → prawn_manual_spec.rb} +6 -4
- data/spec/spec_helper.rb +9 -10
- metadata +86 -73
- metadata.gz.sig +4 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# The <code>line_width=</code> method sets the stroke width for subsequent
|
2
4
|
# stroke calls.
|
3
5
|
#
|
@@ -31,3 +33,4 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
31
33
|
y -= 100
|
32
34
|
end
|
33
35
|
end
|
36
|
+
# rubocop: enable Lint/UselessAssignment
|
data/manual/graphics/polygon.rb
CHANGED
data/manual/graphics/rotate.rb
CHANGED
data/manual/graphics/scale.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Soft masks are used for more complex alpha channel manipulations. You can use
|
2
4
|
# arbitrary drawing functions for creation of soft masks. The resulting alpha
|
3
5
|
# channel is made of greyscale version of the drawing (luminosity channel to be
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# The cap style defines how the edge of a line or curve will be drawn. There are
|
2
4
|
# three types: <code>:butt</code> (the default), <code>:round</code> and
|
3
5
|
# <code>:projecting_square</code>
|
@@ -18,7 +20,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
18
20
|
|
19
21
|
self.line_width = 25
|
20
22
|
|
21
|
-
[
|
23
|
+
%i[butt round projecting_square].each_with_index do |cap, i|
|
22
24
|
self.cap_style = cap
|
23
25
|
|
24
26
|
y = 250 - i * 100
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# The join style defines how the intersection between two lines is drawn. There
|
2
4
|
# are three types: <code>:miter</code> (the default), <code>:round</code> and
|
3
5
|
# <code>:bevel</code>
|
@@ -13,7 +15,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
13
15
|
|
14
16
|
self.line_width = 25
|
15
17
|
|
16
|
-
[
|
18
|
+
%i[miter round bevel].each_with_index do |style, i|
|
17
19
|
self.join_style = style
|
18
20
|
|
19
21
|
y = 200 - i * 100
|
data/manual/images/fit.rb
CHANGED
data/manual/images/horizontal.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# The image may be positioned relatively to the current bounding box. The
|
2
4
|
# horizontal position may be set with the <code>:position</code> option.
|
3
5
|
#
|
@@ -11,7 +13,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
11
13
|
bounding_box([50, cursor], width: 400, height: 450) do
|
12
14
|
stroke_bounds
|
13
15
|
|
14
|
-
[
|
16
|
+
%i[left center right].each do |position|
|
15
17
|
text "Image aligned to the #{position}."
|
16
18
|
image "#{Prawn::DATADIR}/images/stef.jpg", position: position
|
17
19
|
end
|
data/manual/images/images.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Examples for embedding images.
|
2
4
|
|
3
5
|
require_relative '../example_helper'
|
@@ -21,12 +23,12 @@ Prawn::ManualBuilder::Example.generate('images.pdf', page_size: 'FOLIO') do
|
|
21
23
|
end
|
22
24
|
|
23
25
|
p.intro do
|
24
|
-
prose <<-
|
26
|
+
prose <<-TEXT
|
25
27
|
Embedding images on PDF documents is fairly easy. Prawn supports both
|
26
28
|
JPG and PNG images.
|
27
29
|
|
28
30
|
The examples show:
|
29
|
-
|
31
|
+
TEXT
|
30
32
|
|
31
33
|
list(
|
32
34
|
'How to add an image to a page',
|
data/manual/images/scale.rb
CHANGED
data/manual/images/vertical.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# To set the vertical position of an image use the <code>:vposition</code>
|
2
4
|
# option.
|
3
5
|
#
|
@@ -11,7 +13,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
11
13
|
bounding_box([0, cursor], width: 500, height: 450) do
|
12
14
|
stroke_bounds
|
13
15
|
|
14
|
-
[
|
16
|
+
%i[top center bottom].each do |vposition|
|
15
17
|
text "Image vertically aligned to the #{vposition}.", valign: vposition
|
16
18
|
image "#{Prawn::DATADIR}/images/stef.jpg",
|
17
19
|
position: 250, vposition: vposition
|
data/manual/layout/boxes.rb
CHANGED
data/manual/layout/content.rb
CHANGED
data/manual/layout/layout.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Examples for using grid layouts.
|
2
4
|
|
3
5
|
require_relative '../example_helper'
|
@@ -9,11 +11,11 @@ Prawn::ManualBuilder::Example.generate('layout.pdf', page_size: 'FOLIO') do
|
|
9
11
|
p.example 'content'
|
10
12
|
|
11
13
|
p.intro do
|
12
|
-
prose <<-
|
14
|
+
prose <<-TEXT
|
13
15
|
Prawn has support for two-dimensional grid based layouts out of the box.
|
14
16
|
|
15
17
|
The examples show:
|
16
|
-
|
18
|
+
TEXT
|
17
19
|
|
18
20
|
list(
|
19
21
|
'How to define the document grid',
|
data/manual/outline/outline.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Examples for defining the document outline.
|
2
4
|
|
3
5
|
require_relative '../example_helper'
|
@@ -14,12 +16,12 @@ Prawn::ManualBuilder::Example.generate('outline.pdf', page_size: 'FOLIO') do
|
|
14
16
|
end
|
15
17
|
|
16
18
|
p.intro do
|
17
|
-
prose <<-
|
19
|
+
prose <<-TEXT
|
18
20
|
The outline of a PDF document is the table of contents tab you see to
|
19
21
|
the right or left of your PDF viewer.
|
20
22
|
|
21
23
|
The examples include:
|
22
|
-
|
24
|
+
TEXT
|
23
25
|
|
24
26
|
list(
|
25
27
|
'How to define sections and pages',
|
@@ -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'
|
@@ -11,7 +13,7 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
|
|
11
13
|
p.example 'alternate_page_numbering', eval_source: false
|
12
14
|
|
13
15
|
p.intro do
|
14
|
-
prose <<-
|
16
|
+
prose <<-TEXT
|
15
17
|
Prawn offers two ways to handle repeatable content blocks. Repeater is
|
16
18
|
useful for content that gets repeated at well defined intervals while
|
17
19
|
Stamp is more appropriate if you need better control of when to repeat
|
@@ -20,7 +22,7 @@ Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do
|
|
20
22
|
There is also one very specific helper for numbering pages.
|
21
23
|
|
22
24
|
The examples show:
|
23
|
-
|
25
|
+
TEXT
|
24
26
|
|
25
27
|
list(
|
26
28
|
'How to repeat content on several pages with a single invocation',
|
data/manual/security/security.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Examples for document encryption.
|
2
4
|
|
3
5
|
require_relative '../example_helper'
|
@@ -8,12 +10,12 @@ Prawn::ManualBuilder::Example.generate('security.pdf', page_size: 'FOLIO') do
|
|
8
10
|
p.example 'permissions', eval_source: false, full_source: true
|
9
11
|
|
10
12
|
p.intro do
|
11
|
-
prose <<-
|
13
|
+
prose <<-TEXT
|
12
14
|
Security lets you control who can read the document by defining
|
13
15
|
a password.
|
14
16
|
|
15
17
|
The examples include:
|
16
|
-
|
18
|
+
TEXT
|
17
19
|
|
18
20
|
list(
|
19
21
|
'How to encrypt the document without the need for a password',
|
data/manual/table.rb
CHANGED
data/manual/text/alignment.rb
CHANGED
data/manual/text/color.rb
CHANGED
data/manual/text/column_box.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# The <code>column_box</code> method allows you to define columns that flow
|
2
4
|
# their contents from one section to the next. You can have a number of columns
|
3
5
|
# on the page, and only when the last column overflows will a new page be
|
@@ -12,7 +14,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
12
14
|
move_down 12
|
13
15
|
|
14
16
|
column_box([0, cursor], columns: 2, width: bounds.width) do
|
15
|
-
text((<<-
|
17
|
+
text((<<-TEXT.gsub(/\s+/, ' ') + "\n\n") * 3)
|
16
18
|
All the States and Governments by which men are or ever have been ruled,
|
17
19
|
have been and are either Republics or Princedoms. Princedoms are either
|
18
20
|
hereditary, in which the sovereignty is derived through an ancient line
|
@@ -23,6 +25,6 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
23
25
|
acquired have either been used to live under a Prince or have been free;
|
24
26
|
and he who acquires them does so either by his own arms or by the arms of
|
25
27
|
others, and either by good fortune or by merit.
|
26
|
-
|
28
|
+
TEXT
|
27
29
|
end
|
28
30
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Prawn enables the declaration of fallback fonts for those glyphs that may not
|
2
4
|
# be present in the desired font. Use the <code>:fallback_fonts</code> option
|
3
5
|
# with any of the text or text box methods, or set fallback_fonts document-wide.
|
@@ -24,7 +26,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
24
26
|
'to right.' \
|
25
27
|
"\n\n" \
|
26
28
|
"hello ƒ 你好\n再见 ƒ goodbye",
|
27
|
-
fallback_fonts: [
|
29
|
+
fallback_fonts: %w[Times-Roman Kai]
|
28
30
|
)
|
29
31
|
end
|
30
32
|
move_down 20
|
@@ -34,6 +36,6 @@ Prawn::ManualBuilder::Example.generate(filename) do
|
|
34
36
|
{ text: 'Fallback fonts can even override' },
|
35
37
|
{ text: 'fragment fonts (你好)', font: 'Times-Roman' }
|
36
38
|
],
|
37
|
-
fallback_fonts: [
|
39
|
+
fallback_fonts: %w[Times-Roman Kai]
|
38
40
|
)
|
39
41
|
end
|
data/manual/text/font.rb
CHANGED