prawn 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GPLv2 +340 -0
- data/GPLv3 +674 -0
- data/README.md +96 -0
- data/Rakefile +0 -12
- data/examples/example_helper.rb +3 -0
- data/lib/prawn.rb +1 -1
- data/lib/prawn/core/page.rb +4 -2
- data/lib/prawn/core/pdf_object.rb +7 -7
- data/lib/prawn/core/text/formatted/arranger.rb +2 -1
- data/lib/prawn/core/text/formatted/line_wrap.rb +2 -1
- data/lib/prawn/core/text/formatted/wrap.rb +5 -1
- data/lib/prawn/document.rb +135 -112
- data/lib/prawn/document/bounding_box.rb +51 -5
- data/lib/prawn/document/column_box.rb +0 -19
- data/lib/prawn/document/internals.rb +1 -0
- data/lib/prawn/document/snapshot.rb +3 -0
- data/lib/prawn/font.rb +4 -3
- data/lib/prawn/font/afm.rb +11 -2
- data/lib/prawn/font/ttf.rb +15 -0
- data/lib/prawn/images.rb +1 -1
- data/lib/prawn/table.rb +23 -7
- data/lib/prawn/table/cell.rb +31 -9
- data/lib/prawn/table/cell/text.rb +2 -2
- data/prawn.gemspec +5 -6
- data/spec/bounding_box_spec.rb +157 -0
- data/spec/data/curves.pdf +66 -0
- data/spec/document_spec.rb +59 -4
- data/spec/extensions/mocha.rb +1 -3
- data/spec/font_spec.rb +23 -0
- data/spec/formatted_text_box_spec.rb +40 -0
- data/spec/images_spec.rb +7 -0
- data/spec/object_store_spec.rb +3 -3
- data/spec/snapshot_spec.rb +33 -0
- data/spec/table_spec.rb +75 -0
- data/spec/template_spec.rb +11 -5
- data/spec/text_spacing_spec.rb +18 -0
- data/spec/text_spec.rb +32 -0
- metadata +217 -283
- data/HACKING +0 -50
- data/README +0 -141
- data/examples/bounding_box/bounding_boxes.rb +0 -44
- data/examples/bounding_box/indentation.rb +0 -35
- data/examples/bounding_box/stretched_nesting.rb +0 -68
- data/examples/general/background.rb +0 -24
- data/examples/general/canvas.rb +0 -16
- data/examples/general/float.rb +0 -12
- data/examples/general/margin.rb +0 -37
- data/examples/general/measurement_units.rb +0 -52
- data/examples/general/metadata-info.rb +0 -17
- data/examples/general/multi_page_layout.rb +0 -19
- data/examples/general/outlines.rb +0 -67
- data/examples/general/page_geometry.rb +0 -32
- data/examples/general/page_numbering.rb +0 -40
- data/examples/general/page_templates.rb +0 -20
- data/examples/general/repeaters.rb +0 -48
- data/examples/general/stamp.rb +0 -42
- data/examples/general/templates.rb +0 -14
- data/examples/graphics/basic_images.rb +0 -24
- data/examples/graphics/curves.rb +0 -12
- data/examples/graphics/hexagon.rb +0 -14
- data/examples/graphics/image_fit.rb +0 -16
- data/examples/graphics/image_flow.rb +0 -38
- data/examples/graphics/image_position.rb +0 -18
- data/examples/graphics/line.rb +0 -33
- data/examples/graphics/polygons.rb +0 -17
- data/examples/graphics/rounded_polygons.rb +0 -20
- data/examples/graphics/rounded_rectangle.rb +0 -21
- data/examples/graphics/ruport_style_helpers.rb +0 -20
- data/examples/graphics/stroke_bounds.rb +0 -21
- data/examples/graphics/stroke_cap_and_join.rb +0 -46
- data/examples/graphics/stroke_dash.rb +0 -43
- data/examples/graphics/transformations.rb +0 -53
- data/examples/graphics/transparency.rb +0 -27
- data/examples/grid/bounding_boxes.rb +0 -22
- data/examples/grid/column_gutter_grid.rb +0 -21
- data/examples/grid/multi_boxes.rb +0 -52
- data/examples/grid/show_grid.rb +0 -14
- data/examples/grid/simple_grid.rb +0 -21
- data/examples/m17n/chinese_text_wrapping.rb +0 -18
- data/examples/m17n/euro.rb +0 -16
- data/examples/m17n/utf8.rb +0 -14
- data/examples/security/hello_foo.rb +0 -9
- data/examples/table/borders.rb +0 -25
- data/examples/table/cell.rb +0 -13
- data/examples/table/checkerboard.rb +0 -23
- data/examples/table/inline_format_table.rb +0 -13
- data/examples/table/multi_page_table.rb +0 -10
- data/examples/table/simple_table.rb +0 -25
- data/examples/table/subtable.rb +0 -13
- data/examples/table/widths.rb +0 -21
- data/examples/text/alignment.rb +0 -19
- data/examples/text/character_spacing.rb +0 -13
- data/examples/text/dfont.rb +0 -49
- data/examples/text/family_based_styling.rb +0 -25
- data/examples/text/font_size.rb +0 -34
- data/examples/text/inline_format.rb +0 -104
- data/examples/text/kerning.rb +0 -31
- data/examples/text/rendering_mode.rb +0 -21
- data/examples/text/rotated.rb +0 -99
- data/examples/text/shaped_text_box.rb +0 -32
- data/examples/text/simple_text.rb +0 -18
- data/examples/text/simple_text_ttf.rb +0 -18
- data/examples/text/span.rb +0 -30
- data/examples/text/text_box.rb +0 -90
- data/examples/text/text_box_returning_excess.rb +0 -52
- data/examples/text/text_flow.rb +0 -68
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Example of character spacing
|
4
|
-
#
|
5
|
-
#
|
6
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
-
%w[.. example_helper]))
|
8
|
-
|
9
|
-
Prawn::Document.generate "rendering_mode.pdf" do |pdf|
|
10
|
-
pdf.fill_color "00ff00"
|
11
|
-
pdf.stroke_color "0000ff"
|
12
|
-
|
13
|
-
# inline rendering mode
|
14
|
-
pdf.text("Inline mode", :mode => :stroke, :size => 40)
|
15
|
-
|
16
|
-
# block rendering mode
|
17
|
-
pdf.text_rendering_mode(:stroke) do
|
18
|
-
pdf.text("Block", :size => 30)
|
19
|
-
pdf.text("Mode", :size => 30)
|
20
|
-
end
|
21
|
-
end
|
data/examples/text/rotated.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Demonstrates transformations
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Document.generate "rotated_text.pdf" do |pdf|
|
9
|
-
pdf.line_width = 1
|
10
|
-
width = 150
|
11
|
-
height = 200
|
12
|
-
half_width = width / 2
|
13
|
-
half_height = height / 2
|
14
|
-
angle = 30
|
15
|
-
|
16
|
-
|
17
|
-
# AROUND THE CENTER
|
18
|
-
|
19
|
-
x = pdf.bounds.width / 2 - half_width
|
20
|
-
y = pdf.bounds.height / 2 + half_height
|
21
|
-
|
22
|
-
pdf.stroke_rectangle([x, y], width, height)
|
23
|
-
pdf.rotate(angle, :origin => [x + half_width, y - half_height]) do
|
24
|
-
pdf.stroke_rectangle([x, y], width, height)
|
25
|
-
end
|
26
|
-
pdf.text_box("rotated around the center " * 10,
|
27
|
-
:at => [x, y],
|
28
|
-
:width => width,
|
29
|
-
:height => height,
|
30
|
-
:rotate => angle,
|
31
|
-
:rotate_around => :center)
|
32
|
-
|
33
|
-
|
34
|
-
# AROUND THE UPPER_LEFT_CORNER
|
35
|
-
|
36
|
-
x = pdf.bounds.width - width
|
37
|
-
y = height
|
38
|
-
|
39
|
-
pdf.stroke_rectangle([x, y], width, height)
|
40
|
-
pdf.rotate(angle, :origin => [x, y]) do
|
41
|
-
pdf.stroke_rectangle([x, y], width, height)
|
42
|
-
end
|
43
|
-
pdf.text_box("rotated around upper left corner " * 10,
|
44
|
-
:at => [x, y],
|
45
|
-
:width => width,
|
46
|
-
:height => height,
|
47
|
-
:rotate => angle)
|
48
|
-
|
49
|
-
|
50
|
-
# AROUND THE UPPER_RIGHT_CORNER
|
51
|
-
|
52
|
-
x = 0
|
53
|
-
y = height
|
54
|
-
|
55
|
-
pdf.stroke_rectangle([x, y], width, height)
|
56
|
-
pdf.rotate(angle, :origin => [x + width, y]) do
|
57
|
-
pdf.stroke_rectangle([x, y], width, height)
|
58
|
-
end
|
59
|
-
pdf.text_box("rotated around upper right corner " * 10,
|
60
|
-
:at => [x, y],
|
61
|
-
:width => width,
|
62
|
-
:height => height,
|
63
|
-
:rotate => angle,
|
64
|
-
:rotate_around => :upper_right)
|
65
|
-
|
66
|
-
|
67
|
-
# AROUND THE LOWER_RIGHT_CORNER
|
68
|
-
|
69
|
-
x = 0
|
70
|
-
y = pdf.bounds.height
|
71
|
-
|
72
|
-
pdf.stroke_rectangle([x, y], width, height)
|
73
|
-
pdf.rotate(angle, :origin => [x + width, y - height]) do
|
74
|
-
pdf.stroke_rectangle([x, y], width, height)
|
75
|
-
end
|
76
|
-
pdf.text_box("rotated around lower right corner " * 10,
|
77
|
-
:at => [x, y],
|
78
|
-
:width => width,
|
79
|
-
:height => height,
|
80
|
-
:rotate => angle,
|
81
|
-
:rotate_around => :lower_right)
|
82
|
-
|
83
|
-
|
84
|
-
# AROUND THE LOWER_LEFT_CORNER
|
85
|
-
|
86
|
-
x = pdf.bounds.width - width
|
87
|
-
y = pdf.bounds.height
|
88
|
-
|
89
|
-
pdf.stroke_rectangle([x, y], width, height)
|
90
|
-
pdf.rotate(angle, :origin => [x, y - height]) do
|
91
|
-
pdf.stroke_rectangle([x, y], width, height)
|
92
|
-
end
|
93
|
-
pdf.text_box("rotated around lower left corner " * 10,
|
94
|
-
:at => [x, y],
|
95
|
-
:width => width,
|
96
|
-
:height => height,
|
97
|
-
:rotate => angle,
|
98
|
-
:rotate_around => :lower_left)
|
99
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Demonstrates extending Text::Box
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Document.generate "shaped_text_box.pdf" do |pdf|
|
9
|
-
module ShapedBox
|
10
|
-
def available_width
|
11
|
-
height + 25
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
Prawn::Text::Box.extensions << ShapedBox
|
16
|
-
pdf.stroke_rectangle([10, pdf.bounds.top - 10], 300, 300)
|
17
|
-
pdf.text_box("A" * 500,
|
18
|
-
:at => [10, pdf.bounds.top - 10],
|
19
|
-
:width => 300,
|
20
|
-
:height => 300,
|
21
|
-
:align => :center)
|
22
|
-
|
23
|
-
Prawn::Text::Formatted::Box.extensions << ShapedBox
|
24
|
-
pdf.stroke_rectangle([10, pdf.bounds.top - 330], 300, 300)
|
25
|
-
pdf.formatted_text_box([:text => "A" * 500,
|
26
|
-
:color => "009900"],
|
27
|
-
:at => [10, pdf.bounds.top - 330],
|
28
|
-
:width => 300,
|
29
|
-
:height => 300,
|
30
|
-
:align => :center)
|
31
|
-
end
|
32
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# An early example of basic text generation at absolute positions.
|
4
|
-
# Mostly kept for nostalgia.
|
5
|
-
#
|
6
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
-
%w[.. example_helper]))
|
8
|
-
|
9
|
-
Prawn::Document.generate "simple_text.pdf" do
|
10
|
-
fill_color "0000ff"
|
11
|
-
draw_text "Hello World", :at => [200,420], :size => 32, :rotate => 45
|
12
|
-
font "Times-Roman"
|
13
|
-
fill_color "ff0000"
|
14
|
-
draw_text "Using Another Font", :at => [5,5]
|
15
|
-
start_new_page
|
16
|
-
font "Courier"
|
17
|
-
draw_text "Goodbye World", :at => [288,50]
|
18
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# An early example of TTF font embedding. Mostly kept for nostalgia's sake.
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Document.generate "simple_text_ttf.pdf" do
|
9
|
-
fill_color "0000ff"
|
10
|
-
font "#{Prawn::BASEDIR}/data/fonts/comicsans.ttf"
|
11
|
-
draw_text "Hello World", :at => [200,720], :size => 32
|
12
|
-
|
13
|
-
font "#{Prawn::BASEDIR}/data/fonts/Chalkboard.ttf"
|
14
|
-
|
15
|
-
pad(20) do
|
16
|
-
text "This is chalkboard wrapping " * 20
|
17
|
-
end
|
18
|
-
end
|
data/examples/text/span.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Demonstration of Document#span, which is used for generating flowing
|
4
|
-
# columns of text.
|
5
|
-
#
|
6
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
-
%w[.. example_helper]))
|
8
|
-
|
9
|
-
Prawn::Document.generate("span.pdf") do
|
10
|
-
|
11
|
-
# Spans will typically be used outside of bounding boxes as a way to build
|
12
|
-
# single columns of flowing text that span across pages.
|
13
|
-
#
|
14
|
-
span(350, :position => :center) do
|
15
|
-
text "Here's some centered text in a 350 point column. " * 100
|
16
|
-
end
|
17
|
-
|
18
|
-
# Spans are not really compatible with bounding boxes because they break
|
19
|
-
# the nesting chain and also may position text outside of the bounding box
|
20
|
-
# boundaries, but sometimes you may wish to use them anyway for convenience
|
21
|
-
# Here's an example of how to do that dynamically.
|
22
|
-
#
|
23
|
-
bounding_box([50,300], :width => 400) do
|
24
|
-
text "Here's some default bounding box text. " * 10
|
25
|
-
span(bounds.width,
|
26
|
-
:position => bounds.absolute_left - margin_box.absolute_left) do
|
27
|
-
text "The rain in spain falls mainly on the plains. " * 300
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/examples/text/text_box.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
|
4
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
5
|
-
%w[.. example_helper]))
|
6
|
-
|
7
|
-
Prawn::Document.generate("text_box.pdf") do
|
8
|
-
def get_string(i, j)
|
9
|
-
case i
|
10
|
-
when 0
|
11
|
-
text = "this is left text " * 30
|
12
|
-
text.insert(48, "\n\n")
|
13
|
-
when 1
|
14
|
-
text = "this is center text " * 30
|
15
|
-
text.insert(54, "\n\n")
|
16
|
-
when 2
|
17
|
-
text = "this is right text " * 30
|
18
|
-
text.insert(51, "\n\n")
|
19
|
-
end
|
20
|
-
|
21
|
-
case j
|
22
|
-
when 0
|
23
|
-
text.split(" ").slice(0..47).join(" ")
|
24
|
-
when 3
|
25
|
-
text.delete(" ")
|
26
|
-
else
|
27
|
-
text
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def get_options(i, j)
|
32
|
-
options = {
|
33
|
-
:width => bounds.width * 0.3,
|
34
|
-
:height => bounds.width * 0.3,
|
35
|
-
:at => [0, 0],
|
36
|
-
:align => :left,
|
37
|
-
:document => self
|
38
|
-
}
|
39
|
-
|
40
|
-
case i
|
41
|
-
when 0
|
42
|
-
options[:valign] = :top if j == 0
|
43
|
-
when 1
|
44
|
-
options[:align] = :center
|
45
|
-
options[:valign] = :center if j == 0
|
46
|
-
when 2
|
47
|
-
options[:align] = :right
|
48
|
-
options[:valign] = :bottom if j == 0
|
49
|
-
end
|
50
|
-
|
51
|
-
case j
|
52
|
-
when 1
|
53
|
-
options[:overflow] = :shrink_to_fit
|
54
|
-
when 2
|
55
|
-
options[:leading] = font.height * 0.5
|
56
|
-
options[:overflow] = :truncate
|
57
|
-
end
|
58
|
-
options
|
59
|
-
end
|
60
|
-
|
61
|
-
stroke_color("555555")
|
62
|
-
3.times do |i|
|
63
|
-
4.times do |j|
|
64
|
-
options = get_options(i, j)
|
65
|
-
options[:at][0] = (bounds.width - options[:width]) * 0.5 * i
|
66
|
-
options[:at][1] = bounds.top - (bounds.height - options[:height]) * 0.33 * j
|
67
|
-
box = Prawn::Text::Box.new(get_string(i, j), options)
|
68
|
-
|
69
|
-
if j >= 2
|
70
|
-
# bound with a box of a particular size, regardless of how
|
71
|
-
# much text it contains
|
72
|
-
fill_color("ffeeee")
|
73
|
-
fill_and_stroke_rectangle(options[:at],
|
74
|
-
options[:width],
|
75
|
-
options[:height])
|
76
|
-
else
|
77
|
-
# bound with a box that exactly fits the printed text using
|
78
|
-
# dry_run look-ahead
|
79
|
-
fill_color("eeeeff")
|
80
|
-
box.render(:dry_run => true)
|
81
|
-
fill_and_stroke_rectangle(box.at,
|
82
|
-
options[:width],
|
83
|
-
box.height)
|
84
|
-
end
|
85
|
-
|
86
|
-
fill_color("000000")
|
87
|
-
box.render
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# A text box is positioned by a top-left corner, width, and height and is
|
4
|
-
# essentially an invisible rectangle that the text will flow within. If the
|
5
|
-
# text exceeds the boundaries, it is either truncated, shrunk-to-fit, or set
|
6
|
-
# to expand beyond the bottom boundary.
|
7
|
-
#
|
8
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
-
%w[.. example_helper]))
|
10
|
-
|
11
|
-
Prawn::Document.generate("text_box_returning_excess.pdf") do
|
12
|
-
|
13
|
-
# Note that without the initial space in p_break, newlines may be eaten by
|
14
|
-
# the wrap/unwrap process that happens inside the text box.
|
15
|
-
p_break = " \n\n"
|
16
|
-
callout = "Lorem ipsum dolor sit amet"
|
17
|
-
lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.#{p_break}Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.#{p_break}Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
18
|
-
|
19
|
-
box_height = font.height * 5
|
20
|
-
|
21
|
-
# Add a callout box that the rest of the text should flow around
|
22
|
-
font_size(18) do
|
23
|
-
text_box callout, {
|
24
|
-
:width => 100,
|
25
|
-
:height => font.height * 3,
|
26
|
-
:overflow => :truncate,
|
27
|
-
:at => [100, bounds.top - box_height - 4]
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
excess_text = text_box lorem + p_break + lorem, {
|
32
|
-
:width => 300,
|
33
|
-
:height => box_height,
|
34
|
-
:overflow => :truncate,
|
35
|
-
:at => [100, bounds.top],
|
36
|
-
}
|
37
|
-
|
38
|
-
excess_text = text_box excess_text, {
|
39
|
-
:width => 200,
|
40
|
-
:height => box_height,
|
41
|
-
:overflow => :truncate,
|
42
|
-
:at => [200, bounds.top - box_height],
|
43
|
-
}
|
44
|
-
|
45
|
-
text_box excess_text, {
|
46
|
-
:width => 300,
|
47
|
-
:height => box_height,
|
48
|
-
:overflow => :expand,
|
49
|
-
:at => [100, bounds.top - box_height * 2],
|
50
|
-
}
|
51
|
-
|
52
|
-
end
|
data/examples/text/text_flow.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Basic text flowing example including the use of bounding boxes. A somewhat
|
4
|
-
# old example, mostly retained for nostalgia.
|
5
|
-
#
|
6
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
-
%w[.. example_helper]))
|
8
|
-
|
9
|
-
content = <<-EOS
|
10
|
-
How does
|
11
|
-
Prawn deal with
|
12
|
-
white
|
13
|
-
space
|
14
|
-
|
15
|
-
and
|
16
|
-
|
17
|
-
line
|
18
|
-
breaks?
|
19
|
-
EOS
|
20
|
-
|
21
|
-
poem = <<-EOS
|
22
|
-
GOOD-BYE
|
23
|
-
|
24
|
-
Good-bye, proud world! I'm going home: Thou art not my friend, and I'm not thine. Long through thy weary crowds I roam; A river-ark on the ocean brine, Long I've been tossed like the driven foam: But now, proud world! I'm going home.
|
25
|
-
|
26
|
-
Good-bye to Flattery's fawning face; To Grandeur with his wise grimace; To upstart Wealth's averted eye; To supple Office, low and high; To crowded halls, to court and street; To frozen hearts and hasting feet; To those who go, and those who come; Good-bye, proud world! I'm going home.
|
27
|
-
|
28
|
-
I am going to my own hearth-stone, Bosomed in yon green hills alone,-- secret nook in a pleasant land, Whose groves the frolic fairies planned; Where arches green, the livelong day, Echo the blackbird's roundelay, And vulgar feet have never trod A spot that is sacred to thought and God.
|
29
|
-
|
30
|
-
O, when I am safe in my sylvan home, I tread on the pride of Greece and Rome; And when I am stretched beneath the pines, Where the evening star so holy shines, I laugh at the lore and the pride of man, At the sophist schools and the learned clan; For what are they all, in their high conceit, When man in the bush with God may meet?
|
31
|
-
EOS
|
32
|
-
|
33
|
-
overflow = "This text should flow gracefully onto the next page, like a stream"+
|
34
|
-
" flows elegantly from a mountain lake down into the village below."
|
35
|
-
|
36
|
-
Prawn::Document.generate("flow.pdf") do |pdf|
|
37
|
-
|
38
|
-
pdf.font "Times-Roman"
|
39
|
-
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
40
|
-
[pdf.bounds.right, pdf.bounds.top]
|
41
|
-
|
42
|
-
pdf.text content, :size => 10
|
43
|
-
|
44
|
-
pdf.bounding_box([100,600], :width => 200, :height => 525) do
|
45
|
-
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
46
|
-
[pdf.bounds.right, pdf.bounds.top]
|
47
|
-
pdf.text poem, :size => 12
|
48
|
-
end
|
49
|
-
|
50
|
-
pdf.bounding_box([325,600], :width => 200, :height => 525) do
|
51
|
-
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
52
|
-
[pdf.bounds.right, pdf.bounds.top]
|
53
|
-
pdf.text poem.reverse, :size => 12
|
54
|
-
end
|
55
|
-
|
56
|
-
pdf.text overflow * 10, :size => 14
|
57
|
-
|
58
|
-
pdf.text "Hooray! We've conquered the evil PDF gods", :size => 36
|
59
|
-
|
60
|
-
pdf.bounding_box([100,450], :width => 300) do
|
61
|
-
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
62
|
-
[pdf.bounds.right, pdf.bounds.top]
|
63
|
-
pdf.text poem, :size => 10, :leading => 5
|
64
|
-
end
|
65
|
-
|
66
|
-
pdf.text "And this text automatically goes below the poem", :size => 18
|
67
|
-
|
68
|
-
end
|