prawn 1.0.0 → 1.1.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 +4 -4
- data/Rakefile +4 -2
- data/lib/prawn.rb +5 -3
- data/lib/prawn/document.rb +7 -7
- data/lib/prawn/document/bounding_box.rb +1 -1
- data/lib/prawn/document/column_box.rb +3 -3
- data/lib/prawn/document/internals.rb +1 -1
- data/lib/prawn/font.rb +24 -8
- data/lib/prawn/font/afm.rb +4 -4
- data/lib/prawn/font_metric_cache.rb +1 -1
- data/lib/prawn/grid.rb +3 -1
- data/lib/prawn/image_handler.rb +3 -1
- data/lib/prawn/images/jpg.rb +1 -1
- data/lib/prawn/measurement_extensions.rb +1 -1
- data/lib/prawn/outline.rb +3 -1
- data/lib/prawn/security.rb +1 -1
- data/lib/prawn/security/arcfour.rb +4 -2
- data/lib/prawn/table.rb +14 -2
- data/lib/prawn/table/cell.rb +1 -1
- data/lib/prawn/table/cells.rb +1 -50
- data/lib/prawn/table/column_width_calculator.rb +131 -10
- data/lib/prawn/text.rb +1 -1
- data/lib/prawn/text/formatted.rb +2 -0
- data/lib/prawn/text/formatted/arranger.rb +1 -1
- data/lib/prawn/text/formatted/box.rb +5 -5
- data/lib/prawn/text/formatted/line_wrap.rb +1 -1
- data/lib/prawn/text/formatted/wrap.rb +2 -0
- data/lib/prawn/utilities.rb +3 -3
- data/manual/absolute_position.pdf +0 -0
- data/manual/basic_concepts/adding_pages.rb +3 -3
- data/manual/basic_concepts/basic_concepts.rb +6 -6
- data/manual/basic_concepts/cursor.rb +5 -5
- data/manual/basic_concepts/measurement.rb +2 -2
- data/manual/basic_concepts/origin.rb +3 -3
- data/manual/basic_concepts/other_cursor_helpers.rb +6 -6
- data/manual/bounding_box/bounding_box.rb +6 -6
- data/manual/bounding_box/bounds.rb +6 -6
- data/manual/bounding_box/canvas.rb +2 -2
- data/manual/bounding_box/creation.rb +3 -3
- data/manual/bounding_box/indentation.rb +9 -9
- data/manual/bounding_box/nesting.rb +8 -8
- data/manual/bounding_box/russian_boxes.rb +1 -1
- data/manual/bounding_box/stretchy.rb +8 -8
- data/manual/{manual/manual.rb → contents.rb} +6 -9
- data/manual/{manual/cover.rb → cover.rb} +6 -6
- data/manual/document_and_page_options/background.rb +2 -2
- data/manual/document_and_page_options/document_and_page_options.rb +4 -4
- data/manual/document_and_page_options/metadata.rb +2 -2
- data/manual/document_and_page_options/page_margins.rb +2 -2
- data/manual/document_and_page_options/page_size.rb +3 -3
- data/manual/example_helper.rb +5 -409
- data/manual/graphics/circle_and_ellipse.rb +4 -4
- data/manual/graphics/color.rb +4 -4
- data/manual/graphics/common_lines.rb +5 -5
- data/manual/graphics/fill_and_stroke.rb +5 -5
- data/manual/graphics/fill_rules.rb +1 -1
- data/manual/graphics/gradients.rb +1 -1
- data/manual/graphics/graphics.rb +8 -8
- data/manual/graphics/helper.rb +1 -1
- data/manual/graphics/line_width.rb +5 -5
- data/manual/graphics/lines_and_curves.rb +5 -5
- data/manual/graphics/polygon.rb +4 -4
- data/manual/graphics/rectangle.rb +3 -3
- data/manual/graphics/rotate.rb +5 -5
- data/manual/graphics/scale.rb +5 -5
- data/manual/graphics/soft_masks.rb +1 -1
- data/manual/graphics/stroke_cap.rb +3 -3
- data/manual/graphics/stroke_dash.rb +1 -1
- data/manual/graphics/stroke_join.rb +4 -4
- data/manual/graphics/translate.rb +5 -5
- data/manual/graphics/transparency.rb +5 -5
- data/manual/{manual/how_to_read_this_manual.rb → how_to_read_this_manual.rb} +16 -17
- data/manual/images/absolute_position.rb +3 -3
- data/manual/images/fit.rb +2 -2
- data/manual/images/horizontal.rb +3 -3
- data/manual/images/images.rb +7 -7
- data/manual/images/plain_image.rb +1 -1
- data/manual/images/scale.rb +3 -3
- data/manual/images/vertical.rb +3 -3
- data/manual/images/width_and_height.rb +3 -3
- data/manual/layout/boxes.rb +4 -4
- data/manual/layout/content.rb +3 -3
- data/manual/layout/layout.rb +5 -5
- data/manual/layout/simple_grid.rb +2 -2
- data/manual/outline/add_subsection_to.rb +7 -7
- data/manual/outline/insert_section_after.rb +5 -5
- data/manual/outline/outline.rb +6 -6
- data/manual/outline/sections_and_pages.rb +9 -9
- data/manual/repeatable_content/page_numbering.rb +3 -3
- data/manual/repeatable_content/repeatable_content.rb +5 -5
- data/manual/repeatable_content/repeater.rb +4 -4
- data/manual/repeatable_content/stamp.rb +4 -4
- data/manual/security/encryption.rb +2 -2
- data/manual/security/permissions.rb +2 -2
- data/manual/security/security.rb +5 -5
- data/manual/table/basic_block.rb +5 -5
- data/manual/table/before_rendering_page.rb +1 -1
- data/manual/table/cell_border_lines.rb +4 -4
- data/manual/table/cell_borders_and_bg.rb +4 -4
- data/manual/table/cell_dimensions.rb +3 -3
- data/manual/table/cell_text.rb +6 -6
- data/manual/table/column_widths.rb +4 -4
- data/manual/table/content_and_subtables.rb +5 -5
- data/manual/table/creation.rb +2 -2
- data/manual/table/filtering.rb +6 -6
- data/manual/table/flow_and_header.rb +2 -2
- data/manual/table/image_cells.rb +1 -1
- data/manual/table/position.rb +1 -1
- data/manual/table/row_colors.rb +3 -3
- data/manual/table/span.rb +1 -1
- data/manual/table/style.rb +3 -3
- data/manual/table/table.rb +7 -7
- data/manual/table/width.rb +3 -3
- data/manual/text/alignment.rb +1 -1
- data/manual/text/color.rb +1 -1
- data/manual/text/column_box.rb +1 -1
- data/manual/text/fallback_fonts.rb +3 -3
- data/manual/text/font.rb +7 -7
- data/manual/text/font_size.rb +9 -9
- data/manual/text/font_style.rb +3 -3
- data/manual/text/formatted_callbacks.rb +3 -3
- data/manual/text/formatted_text.rb +3 -3
- data/manual/text/free_flowing_text.rb +6 -6
- data/manual/text/inline.rb +5 -5
- data/manual/text/kerning_and_character_spacing.rb +7 -7
- data/manual/text/leading.rb +4 -4
- data/manual/text/line_wrapping.rb +4 -4
- data/manual/text/paragraph_indentation.rb +3 -3
- data/manual/text/positioned_text.rb +3 -3
- data/manual/text/registering_families.rb +6 -6
- data/manual/text/rendering_and_color.rb +2 -2
- data/manual/text/right_to_left_text.rb +2 -2
- data/manual/text/rotation.rb +4 -4
- data/manual/text/single_usage.rb +3 -3
- data/manual/text/text.rb +9 -9
- data/manual/text/text_box_excess.rb +2 -2
- data/manual/text/text_box_extensions.rb +3 -3
- data/manual/text/text_box_overflow.rb +4 -4
- data/manual/text/utf8.rb +5 -5
- data/manual/text/win_ansi_charset.rb +1 -1
- data/prawn.gemspec +5 -3
- data/spec/acceptance/png.rb +5 -3
- data/spec/cell_spec.rb +1 -0
- data/spec/column_box_spec.rb +1 -1
- data/spec/extensions/encoding_helpers.rb +2 -0
- data/spec/extensions/mocha.rb +2 -0
- data/spec/font_spec.rb +15 -0
- data/spec/measurement_units_spec.rb +2 -0
- data/spec/repeater_spec.rb +2 -0
- data/spec/soft_mask_spec.rb +2 -0
- data/spec/stamp_spec.rb +2 -0
- data/spec/table_spec.rb +103 -10
- data/spec/text_spec.rb +1 -1
- data/spec/transparency_spec.rb +2 -0
- metadata +42 -18
- data/lib/prawn/layout.rb +0 -17
- data/manual/example_file.rb +0 -111
- data/manual/example_package.rb +0 -53
- data/manual/example_section.rb +0 -46
- data/manual/syntax_highlight.rb +0 -52
data/lib/prawn/text.rb
CHANGED
|
@@ -27,7 +27,7 @@ module Prawn
|
|
|
27
27
|
Prawn::Text::SHY = ""
|
|
28
28
|
|
|
29
29
|
# @group Stable API
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
# If you want text to flow onto a new page or between columns, this is the
|
|
32
32
|
# method to use. If, instead, if you want to place bounded text outside of
|
|
33
33
|
# the flow of a document (for captions, labels, charts, etc.), use Text::Box
|
data/lib/prawn/text/formatted.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Prawn
|
|
|
11
11
|
module Text
|
|
12
12
|
module Formatted
|
|
13
13
|
# @group Stable API
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
# Draws the requested formatted text into a box. When the text overflows
|
|
16
16
|
# the rectangle shrink to fit or truncate the text. Text boxes are
|
|
17
17
|
# independent of the document y position.
|
|
@@ -107,13 +107,13 @@ module Prawn
|
|
|
107
107
|
# used, the text that would have been successfully printed)
|
|
108
108
|
attr_reader :text
|
|
109
109
|
|
|
110
|
-
# True
|
|
110
|
+
# True if nothing printed (or, if <tt>dry_run</tt> was
|
|
111
111
|
# used, nothing would have been successfully printed)
|
|
112
112
|
def nothing_printed?
|
|
113
113
|
@nothing_printed
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
-
# True
|
|
116
|
+
# True if everything printed (or, if <tt>dry_run</tt> was
|
|
117
117
|
# used, everything would have been successfully printed)
|
|
118
118
|
def everything_printed?
|
|
119
119
|
@everything_printed
|
|
@@ -293,7 +293,7 @@ module Prawn
|
|
|
293
293
|
end
|
|
294
294
|
|
|
295
295
|
# @group Extension API
|
|
296
|
-
|
|
296
|
+
|
|
297
297
|
# Example (see Prawn::Text::Core::Formatted::Wrap for what is required
|
|
298
298
|
# of the wrap method if you want to override the default wrapping
|
|
299
299
|
# algorithm):
|
|
@@ -493,7 +493,7 @@ module Prawn
|
|
|
493
493
|
end
|
|
494
494
|
|
|
495
495
|
def process_options
|
|
496
|
-
# must be performed within a save_font
|
|
496
|
+
# must be performed within a save_font block because
|
|
497
497
|
# document.process_text_options sets the font
|
|
498
498
|
@document.process_text_options(@options)
|
|
499
499
|
@font_size = @options[:size]
|
data/lib/prawn/utilities.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Prawn
|
|
|
17
17
|
# We have two interchangeable thread-safe cache implementations:
|
|
18
18
|
|
|
19
19
|
# @private
|
|
20
|
-
class SynchronizedCache
|
|
20
|
+
class SynchronizedCache
|
|
21
21
|
# As an optimization, this could access the hash directly on VMs with a global interpreter lock (like MRI)
|
|
22
22
|
def initialize
|
|
23
23
|
@cache = {}
|
|
@@ -30,9 +30,9 @@ module Prawn
|
|
|
30
30
|
@mutex.synchronize { @cache[key] = value }
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
# @private
|
|
35
|
-
class ThreadLocalCache
|
|
35
|
+
class ThreadLocalCache
|
|
36
36
|
def initialize
|
|
37
37
|
@cache_id = "cache_#{self.object_id}".to_sym
|
|
38
38
|
end
|
|
Binary file
|
|
@@ -17,11 +17,11 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
17
17
|
%w[.. example_helper]))
|
|
18
18
|
|
|
19
19
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
20
|
-
Prawn::Example.generate(filename) do
|
|
20
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
21
21
|
text "We are still on the initial page for this example. Now I'll ask " +
|
|
22
22
|
"Prawn to gently start a new page. Please follow me to the next page."
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
start_new_page
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
text "See. We've left the previous page behind."
|
|
27
27
|
end
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
#
|
|
3
3
|
# Examples for Prawn basic concepts.
|
|
4
4
|
#
|
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
|
6
|
-
%w[.. example_helper]))
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
require_relative "../example_helper"
|
|
7
|
+
|
|
8
|
+
Prawn::ManualBuilder::Example.generate("basic_concepts.pdf", :page_size => "FOLIO") do
|
|
9
|
+
|
|
10
10
|
package "basic_concepts" do |p|
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
p.example "creation", :eval_source => false, :full_source => true
|
|
13
13
|
p.example "origin"
|
|
14
14
|
p.example "cursor"
|
|
15
15
|
p.example "other_cursor_helpers"
|
|
16
16
|
p.example "adding_pages"
|
|
17
17
|
p.example "measurement"
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
p.intro do
|
|
20
20
|
prose("This chapter covers the minimum amount of functionality you'll need to start using Prawn.
|
|
21
21
|
|
|
@@ -16,18 +16,18 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
16
16
|
%w[.. example_helper]))
|
|
17
17
|
|
|
18
18
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
19
|
-
Prawn::Example.generate(filename) do
|
|
19
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
20
20
|
stroke_axis
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
text "the cursor is here: #{cursor}"
|
|
23
23
|
text "now it is here: #{cursor}"
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
move_down 200
|
|
26
26
|
text "on the first move the cursor went down to: #{cursor}"
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
move_up 100
|
|
29
29
|
text "on the second move the cursor went up to: #{cursor}"
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
move_cursor_to 50
|
|
32
32
|
text "on the last move the cursor went directly to: #{cursor}"
|
|
33
33
|
end
|
|
@@ -15,9 +15,9 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
15
15
|
%w[.. example_helper]))
|
|
16
16
|
|
|
17
17
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
18
|
-
Prawn::Example.generate(filename) do
|
|
18
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
19
19
|
require "prawn/measurement_extensions"
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
[:mm, :cm, :dm, :m, :in, :yd, :ft].each do |measurement|
|
|
22
22
|
text "1 #{measurement} in PDF Points: #{1.send(measurement)} pt"
|
|
23
23
|
move_down 5.mm
|
|
@@ -26,11 +26,11 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
26
26
|
%w[.. example_helper]))
|
|
27
27
|
|
|
28
28
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
29
|
-
Prawn::Example.generate(filename) do
|
|
29
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
30
30
|
stroke_axis
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
stroke_circle [0, 0], 10
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
bounding_box([100, 300], :width => 300, :height => 200) do
|
|
35
35
|
stroke_bounds
|
|
36
36
|
stroke_circle [0, 0], 10
|
|
@@ -13,21 +13,21 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
13
13
|
%w[.. example_helper]))
|
|
14
14
|
|
|
15
15
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
16
|
-
Prawn::Example.generate(filename) do
|
|
16
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
17
17
|
stroke_horizontal_rule
|
|
18
18
|
pad(20) { text "Text padded both before and after." }
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
stroke_horizontal_rule
|
|
21
21
|
pad_top(20) { text "Text padded on the top." }
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
stroke_horizontal_rule
|
|
24
24
|
pad_bottom(20) { text "Text padded on the bottom." }
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
stroke_horizontal_rule
|
|
27
27
|
move_down 30
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
text "Text written before the float block."
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
float do
|
|
32
32
|
move_down 30
|
|
33
33
|
bounding_box([0, cursor], :width => 200) do
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),
|
|
6
6
|
%w[.. example_helper]))
|
|
7
7
|
|
|
8
|
-
Prawn::Example.generate("bounding_box.pdf", :page_size => "FOLIO") do
|
|
9
|
-
|
|
8
|
+
Prawn::ManualBuilder::Example.generate("bounding_box.pdf", :page_size => "FOLIO") do
|
|
9
|
+
|
|
10
10
|
package "bounding_box" do |p|
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
p.section "Basics" do |s|
|
|
13
13
|
s.example "creation"
|
|
14
14
|
s.example "bounds"
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
p.section "Advanced" do |s|
|
|
18
18
|
s.example "stretchy"
|
|
19
19
|
s.example "nesting"
|
|
@@ -21,7 +21,7 @@ Prawn::Example.generate("bounding_box.pdf", :page_size => "FOLIO") do
|
|
|
21
21
|
s.example "canvas"
|
|
22
22
|
s.example "russian_boxes"
|
|
23
23
|
end
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
p.intro do
|
|
26
26
|
prose("Bounding boxes are the basic containers for structuring the content flow. Even being low level building blocks sometimes their simplicity is very welcome.
|
|
27
27
|
|
|
@@ -34,6 +34,6 @@ Prawn::Example.generate("bounding_box.pdf", :page_size => "FOLIO") do
|
|
|
34
34
|
"Indent blocks"
|
|
35
35
|
)
|
|
36
36
|
end
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
-
#
|
|
2
|
+
#
|
|
3
3
|
# The <code>bounds</code> method returns the current bounding box. This is
|
|
4
4
|
# useful because the <code>Prawn::BoundinBox</code> exposes some nice boundary
|
|
5
5
|
# helpers.
|
|
@@ -21,25 +21,25 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
21
21
|
%w[.. example_helper]))
|
|
22
22
|
|
|
23
23
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
24
|
-
Prawn::Example.generate(filename) do
|
|
24
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
25
25
|
def print_coordinates
|
|
26
26
|
text "top: #{bounds.top}"
|
|
27
27
|
text "bottom: #{bounds.bottom}"
|
|
28
28
|
text "left: #{bounds.left}"
|
|
29
29
|
text "right: #{bounds.right}"
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
move_down 10
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
text "absolute top: #{sprintf "%.2f", bounds.absolute_top}"
|
|
34
34
|
text "absolute bottom: #{sprintf "%.2f", bounds.absolute_bottom}"
|
|
35
35
|
text "absolute left: #{sprintf "%.2f", bounds.absolute_left}"
|
|
36
36
|
text "absolute right: #{sprintf "%.2f", bounds.absolute_right}"
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
text "Margin box bounds:"
|
|
40
40
|
move_down 5
|
|
41
41
|
print_coordinates
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
bounding_box([250, cursor + 140], :width => 200, :height => 150) do
|
|
44
44
|
text "This bounding box bounds:"
|
|
45
45
|
move_down 5
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
-
#
|
|
2
|
+
#
|
|
3
3
|
# The origin example already mentions that a new document already comes with
|
|
4
4
|
# a margin box whose bottom left corner is used as the origin for calculating
|
|
5
5
|
# coordinates.
|
|
@@ -14,7 +14,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
14
14
|
%w[.. example_helper]))
|
|
15
15
|
|
|
16
16
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
17
|
-
Prawn::Example.generate(filename) do
|
|
17
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
18
18
|
canvas do
|
|
19
19
|
fill_circle [bounds.left, bounds.top], 30
|
|
20
20
|
fill_circle [bounds.right, bounds.top], 30
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
-
#
|
|
2
|
+
#
|
|
3
3
|
# If you've read the basic concepts examples you probably know that the origin
|
|
4
4
|
# of a page is on the bottom left corner and that the content flows from top to
|
|
5
5
|
# bottom.
|
|
@@ -14,10 +14,10 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
14
14
|
%w[.. example_helper]))
|
|
15
15
|
|
|
16
16
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
17
|
-
Prawn::Example.generate(filename) do
|
|
17
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
18
18
|
bounding_box([200, cursor - 100], :width => 200, :height => 100) do
|
|
19
19
|
text "Just your regular bounding box"
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
transparent(0.5) { stroke_bounds }
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
-
#
|
|
2
|
+
#
|
|
3
3
|
# Sometimes you just need to indent a portion of the contents of a bounding box,
|
|
4
4
|
# and using a nested bounding box is pure overkill. The <code>indent</code>
|
|
5
5
|
# method is what you might need.
|
|
6
6
|
#
|
|
7
7
|
# Just provide a number for it to indent all content generated inside the
|
|
8
|
-
# block.
|
|
8
|
+
# block.
|
|
9
9
|
#
|
|
10
10
|
require File.expand_path(File.join(File.dirname(__FILE__),
|
|
11
11
|
%w[.. example_helper]))
|
|
12
12
|
|
|
13
13
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
14
|
-
Prawn::Example.generate(filename) do
|
|
14
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
15
15
|
text "No indentation on the margin box."
|
|
16
16
|
indent(20) do
|
|
17
17
|
text "Some indentation inside an indent block."
|
|
18
18
|
end
|
|
19
19
|
move_down 20
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
bounding_box([50, cursor], :width => 400, :height => cursor) do
|
|
22
22
|
transparent(0.5) { stroke_bounds }
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
move_down 10
|
|
25
25
|
text "No indentation inside this bounding box."
|
|
26
26
|
indent(40) do
|
|
27
27
|
text "Inside an indent block. And so is this horizontal line:"
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
stroke_horizontal_rule
|
|
30
30
|
end
|
|
31
31
|
move_down 10
|
|
32
32
|
text "No indentation"
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
move_down 20
|
|
35
35
|
indent(60) do
|
|
36
36
|
text "Another indent block."
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
bounding_box([0, cursor], :width => 200) do
|
|
39
39
|
text "Note that this bounding box coordinates are relative to the " +
|
|
40
40
|
"indent block"
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
transparent(0.5) { stroke_bounds }
|
|
43
43
|
end
|
|
44
44
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
-
#
|
|
2
|
+
#
|
|
3
3
|
# Normally when we provide the top left corner of a bounding box we
|
|
4
4
|
# express the coordinates relative to the margin box. This is not the
|
|
5
5
|
# case when we have nested bounding boxes. Once nested the inner bounding box
|
|
@@ -13,31 +13,31 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
13
13
|
%w[.. example_helper]))
|
|
14
14
|
|
|
15
15
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
16
|
-
Prawn::Example.generate(filename) do
|
|
16
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
17
17
|
def box_content(string)
|
|
18
18
|
text string
|
|
19
19
|
transparent(0.5) { stroke_bounds }
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
gap = 20
|
|
23
23
|
bounding_box([50, cursor], :width => 400, :height => 200) do
|
|
24
24
|
box_content("Fixed height")
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
bounding_box([gap, cursor - gap], :width => 300) do
|
|
27
27
|
text "Stretchy height"
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
bounding_box([gap, bounds.top - gap], :width => 100) do
|
|
30
30
|
text "Stretchy height"
|
|
31
31
|
transparent(0.5) { dash(1); stroke_bounds; undash }
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
bounding_box([gap * 7, bounds.top - gap], :width => 100, :height => 50) do
|
|
35
35
|
box_content("Fixed height")
|
|
36
36
|
end
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
transparent(0.5) { dash(1); stroke_bounds; undash }
|
|
39
39
|
end
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
bounding_box([gap, cursor - gap], :width => 300, :height => 50) do
|
|
42
42
|
box_content("Fixed height")
|
|
43
43
|
end
|
|
@@ -8,7 +8,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
|
8
8
|
%w[.. example_helper]))
|
|
9
9
|
|
|
10
10
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
|
11
|
-
Prawn::Example.generate(filename) do
|
|
11
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
|
12
12
|
def combine(a1, a2)
|
|
13
13
|
output = []
|
|
14
14
|
a1.each do |i1|
|