prawn 0.11.1.pre → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +2 -340
- data/HACKING +1 -1
- data/LICENSE +3 -3
- data/Rakefile +17 -6
- data/data/encodings/win_ansi.txt +1 -1
- data/data/images/prawn.png +0 -0
- data/data/pdfs/form.pdf +820 -0
- data/data/pdfs/multipage_template.pdf +127 -0
- data/examples/bounding_box/bounding_boxes.rb +4 -3
- data/examples/bounding_box/indentation.rb +2 -1
- data/examples/bounding_box/russian_boxes.rb +3 -2
- data/examples/bounding_box/stretched_nesting.rb +2 -1
- data/examples/general/background.rb +2 -1
- data/examples/general/canvas.rb +2 -1
- data/examples/general/context_sensitive_headers.rb +2 -1
- data/examples/general/float.rb +2 -1
- data/examples/general/margin.rb +2 -1
- data/examples/general/measurement_units.rb +2 -1
- data/examples/general/metadata-info.rb +2 -1
- data/examples/general/multi_page_layout.rb +2 -1
- data/examples/general/outlines.rb +2 -1
- data/examples/general/page_geometry.rb +2 -1
- data/examples/general/page_numbering.rb +27 -2
- data/examples/general/page_templates.rb +20 -0
- data/examples/general/repeaters.rb +2 -1
- data/examples/general/stamp.rb +4 -3
- data/examples/general/templates.rb +2 -1
- data/examples/graphics/basic_images.rb +2 -1
- data/examples/graphics/cmyk.rb +2 -1
- data/examples/graphics/curves.rb +4 -3
- data/examples/graphics/gradient.rb +23 -0
- data/examples/graphics/hexagon.rb +3 -2
- data/examples/graphics/image_fit.rb +3 -2
- data/examples/graphics/image_flow.rb +2 -1
- data/examples/graphics/image_position.rb +3 -2
- data/examples/graphics/line.rb +2 -1
- data/examples/graphics/png_types.rb +3 -2
- data/examples/graphics/polygons.rb +3 -2
- data/examples/graphics/remote_images.rb +2 -1
- data/examples/graphics/rounded_polygons.rb +2 -1
- data/examples/graphics/rounded_rectangle.rb +2 -1
- data/examples/graphics/ruport_style_helpers.rb +3 -2
- data/examples/graphics/stroke_bounds.rb +2 -1
- data/examples/graphics/stroke_cap_and_join.rb +2 -1
- data/examples/graphics/stroke_dash.rb +2 -1
- data/examples/graphics/transformations.rb +2 -1
- data/examples/graphics/transparency.rb +4 -3
- data/examples/grid/bounding_boxes.rb +2 -1
- data/examples/grid/column_gutter_grid.rb +2 -1
- data/examples/grid/multi_boxes.rb +2 -1
- data/examples/grid/show_grid.rb +2 -1
- data/examples/grid/simple_grid.rb +2 -1
- data/examples/m17n/chinese_text_wrapping.rb +2 -1
- data/examples/m17n/euro.rb +3 -2
- data/examples/m17n/full_win_ansi_character_list.rb +20 -0
- data/examples/m17n/sjis.rb +2 -1
- data/examples/m17n/utf8.rb +3 -2
- data/examples/m17n/win_ansi_charset.rb +2 -1
- data/examples/security/hello_foo.rb +2 -1
- data/examples/table/bill.rb +2 -1
- data/examples/table/borders.rb +25 -0
- data/examples/table/cell.rb +3 -2
- data/examples/table/checkerboard.rb +2 -1
- data/examples/table/header.rb +3 -2
- data/examples/table/inline_format_table.rb +2 -1
- data/examples/table/multi_page_table.rb +2 -1
- data/examples/table/simple_table.rb +2 -1
- data/examples/table/subtable.rb +2 -1
- data/examples/table/widths.rb +2 -1
- data/examples/text/alignment.rb +2 -1
- data/examples/text/character_spacing.rb +2 -1
- data/examples/text/dfont.rb +2 -1
- data/examples/text/family_based_styling.rb +3 -2
- data/examples/text/font_calculations.rb +2 -1
- data/examples/text/font_size.rb +2 -1
- data/examples/text/hyphenation.rb +2 -2
- data/examples/text/indent_paragraphs.rb +7 -5
- data/examples/text/inline_format.rb +7 -6
- data/examples/text/kerning.rb +2 -1
- data/examples/text/rendering_mode.rb +21 -0
- data/examples/text/rotated.rb +2 -1
- data/examples/text/shaped_text_box.rb +2 -1
- data/examples/text/simple_text.rb +2 -1
- data/examples/text/simple_text_ttf.rb +2 -1
- data/examples/text/span.rb +3 -2
- data/examples/text/text_box.rb +7 -5
- data/examples/text/text_box_returning_excess.rb +4 -3
- data/examples/text/text_flow.rb +2 -1
- data/lib/prawn.rb +1 -1
- data/lib/prawn/core/object_store.rb +42 -14
- data/lib/prawn/core/page.rb +22 -8
- data/lib/prawn/core/text.rb +141 -13
- data/lib/prawn/core/text/formatted/arranger.rb +39 -12
- data/lib/prawn/core/text/formatted/line_wrap.rb +205 -60
- data/lib/prawn/core/text/formatted/wrap.rb +72 -35
- data/lib/prawn/document.rb +174 -70
- data/lib/prawn/document/bounding_box.rb +122 -83
- data/lib/prawn/document/column_box.rb +113 -0
- data/lib/prawn/document/graphics_state.rb +90 -2
- data/lib/prawn/document/internals.rb +5 -3
- data/lib/prawn/errors.rb +5 -0
- data/lib/prawn/font.rb +4 -4
- data/lib/prawn/font/afm.rb +11 -0
- data/lib/prawn/font/ttf.rb +5 -0
- data/lib/prawn/graphics.rb +77 -14
- data/lib/prawn/graphics/cap_style.rb +13 -5
- data/lib/prawn/graphics/color.rb +54 -35
- data/lib/prawn/graphics/dash.rb +27 -16
- data/lib/prawn/graphics/gradient.rb +84 -0
- data/lib/prawn/graphics/join_style.rb +12 -3
- data/lib/prawn/graphics/transparency.rb +4 -4
- data/lib/prawn/images.rb +18 -160
- data/lib/prawn/images/jpg.rb +39 -0
- data/lib/prawn/images/png.rb +130 -0
- data/lib/prawn/repeater.rb +6 -13
- data/lib/prawn/security.rb +6 -1
- data/lib/prawn/stamp.rb +12 -4
- data/lib/prawn/table.rb +36 -4
- data/lib/prawn/table/cell.rb +224 -63
- data/lib/prawn/table/cell/text.rb +20 -10
- data/lib/prawn/table/cells.rb +23 -6
- data/lib/prawn/text.rb +54 -91
- data/lib/prawn/text/box.rb +29 -283
- data/lib/prawn/text/formatted/box.rb +349 -24
- data/lib/prawn/text/formatted/fragment.rb +63 -2
- data/lib/prawn/text/formatted/parser.rb +2 -1
- data/prawn.gemspec +21 -5
- data/spec/bounding_box_spec.rb +61 -28
- data/spec/cell_spec.rb +168 -30
- data/spec/document_spec.rb +187 -3
- data/spec/extensions/mocha.rb +45 -0
- data/spec/font_spec.rb +32 -1
- data/spec/formatted_text_arranger_spec.rb +35 -40
- data/spec/formatted_text_box_spec.rb +287 -443
- data/spec/formatted_text_fragment_spec.rb +87 -0
- data/spec/graphics_spec.rb +128 -12
- data/spec/grid_spec.rb +1 -1
- data/spec/images_spec.rb +11 -3
- data/spec/inline_formatted_text_parser_spec.rb +8 -0
- data/spec/line_wrap_spec.rb +200 -208
- data/spec/object_store_spec.rb +10 -0
- data/spec/outline_spec.rb +7 -3
- data/spec/repeater_spec.rb +58 -10
- data/spec/security_spec.rb +6 -0
- data/spec/spec_helper.rb +12 -8
- data/spec/stamp_spec.rb +52 -1
- data/spec/stroke_styles_spec.rb +30 -0
- data/spec/table_spec.rb +93 -3
- data/spec/template_spec.rb +132 -6
- data/spec/text_at_spec.rb +14 -4
- data/spec/text_box_spec.rb +309 -70
- data/spec/text_rendering_mode_spec.rb +45 -0
- data/spec/text_spec.rb +60 -17
- data/spec/text_with_inline_formatting_spec.rb +4 -162
- metadata +241 -241
- data/lib/prawn/core/text/line_wrap.rb +0 -211
- data/lib/prawn/core/text/wrap.rb +0 -82
- data/vendor/pdf-inspector/README +0 -18
- data/vendor/pdf-inspector/lib/pdf/inspector.rb +0 -26
- data/vendor/pdf-inspector/lib/pdf/inspector/extgstate.rb +0 -18
- data/vendor/pdf-inspector/lib/pdf/inspector/graphics.rb +0 -131
- data/vendor/pdf-inspector/lib/pdf/inspector/page.rb +0 -25
- data/vendor/pdf-inspector/lib/pdf/inspector/text.rb +0 -46
- data/vendor/pdf-inspector/lib/pdf/inspector/xobject.rb +0 -19
- data/vendor/ttfunk/data/fonts/DejaVuSans.ttf +0 -0
- data/vendor/ttfunk/data/fonts/comicsans.ttf +0 -0
- data/vendor/ttfunk/example.rb +0 -45
- data/vendor/ttfunk/lib/ttfunk.rb +0 -102
- data/vendor/ttfunk/lib/ttfunk/directory.rb +0 -17
- data/vendor/ttfunk/lib/ttfunk/encoding/mac_roman.rb +0 -88
- data/vendor/ttfunk/lib/ttfunk/encoding/windows_1252.rb +0 -69
- data/vendor/ttfunk/lib/ttfunk/reader.rb +0 -44
- data/vendor/ttfunk/lib/ttfunk/resource_file.rb +0 -78
- data/vendor/ttfunk/lib/ttfunk/subset.rb +0 -18
- data/vendor/ttfunk/lib/ttfunk/subset/base.rb +0 -141
- data/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb +0 -50
- data/vendor/ttfunk/lib/ttfunk/subset/unicode.rb +0 -48
- data/vendor/ttfunk/lib/ttfunk/subset/unicode_8bit.rb +0 -63
- data/vendor/ttfunk/lib/ttfunk/subset/windows_1252.rb +0 -55
- data/vendor/ttfunk/lib/ttfunk/subset_collection.rb +0 -72
- data/vendor/ttfunk/lib/ttfunk/table.rb +0 -46
- data/vendor/ttfunk/lib/ttfunk/table/cmap.rb +0 -34
- data/vendor/ttfunk/lib/ttfunk/table/cmap/format00.rb +0 -54
- data/vendor/ttfunk/lib/ttfunk/table/cmap/format04.rb +0 -126
- data/vendor/ttfunk/lib/ttfunk/table/cmap/subtable.rb +0 -79
- data/vendor/ttfunk/lib/ttfunk/table/glyf.rb +0 -64
- data/vendor/ttfunk/lib/ttfunk/table/glyf/compound.rb +0 -81
- data/vendor/ttfunk/lib/ttfunk/table/glyf/simple.rb +0 -37
- data/vendor/ttfunk/lib/ttfunk/table/head.rb +0 -44
- data/vendor/ttfunk/lib/ttfunk/table/hhea.rb +0 -41
- data/vendor/ttfunk/lib/ttfunk/table/hmtx.rb +0 -47
- data/vendor/ttfunk/lib/ttfunk/table/kern.rb +0 -79
- data/vendor/ttfunk/lib/ttfunk/table/kern/format0.rb +0 -62
- data/vendor/ttfunk/lib/ttfunk/table/loca.rb +0 -43
- data/vendor/ttfunk/lib/ttfunk/table/maxp.rb +0 -40
- data/vendor/ttfunk/lib/ttfunk/table/name.rb +0 -125
- data/vendor/ttfunk/lib/ttfunk/table/os2.rb +0 -78
- data/vendor/ttfunk/lib/ttfunk/table/post.rb +0 -91
- data/vendor/ttfunk/lib/ttfunk/table/post/format10.rb +0 -43
- data/vendor/ttfunk/lib/ttfunk/table/post/format20.rb +0 -35
- data/vendor/ttfunk/lib/ttfunk/table/post/format25.rb +0 -23
- data/vendor/ttfunk/lib/ttfunk/table/post/format30.rb +0 -17
- data/vendor/ttfunk/lib/ttfunk/table/post/format40.rb +0 -17
- data/vendor/ttfunk/lib/ttfunk/table/simple.rb +0 -14
@@ -0,0 +1,127 @@
|
|
1
|
+
%PDF-1.3
|
2
|
+
%����
|
3
|
+
1 0 obj
|
4
|
+
<< /Creator <feff0050007200610077006e>
|
5
|
+
/Producer <feff0050007200610077006e>
|
6
|
+
>>
|
7
|
+
endobj
|
8
|
+
2 0 obj
|
9
|
+
<< /Type /Catalog
|
10
|
+
/Pages 3 0 R
|
11
|
+
>>
|
12
|
+
endobj
|
13
|
+
3 0 obj
|
14
|
+
<< /Type /Pages
|
15
|
+
/Count 3
|
16
|
+
/Kids [5 0 R 8 0 R 10 0 R]
|
17
|
+
>>
|
18
|
+
endobj
|
19
|
+
4 0 obj
|
20
|
+
<< /Length 92
|
21
|
+
>>
|
22
|
+
stream
|
23
|
+
q
|
24
|
+
|
25
|
+
BT
|
26
|
+
36 747.384 Td
|
27
|
+
/F1.0 12 Tf
|
28
|
+
[<546869732069732074656d706c61746520706167652031>] TJ
|
29
|
+
ET
|
30
|
+
|
31
|
+
Q
|
32
|
+
|
33
|
+
endstream
|
34
|
+
endobj
|
35
|
+
5 0 obj
|
36
|
+
<< /Type /Page
|
37
|
+
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
38
|
+
/Font << /F1.0 6 0 R
|
39
|
+
>>
|
40
|
+
>>
|
41
|
+
/Parent 3 0 R
|
42
|
+
/Contents 4 0 R
|
43
|
+
/MediaBox [0 0 612.0 792.0]
|
44
|
+
>>
|
45
|
+
endobj
|
46
|
+
6 0 obj
|
47
|
+
<< /BaseFont /Helvetica
|
48
|
+
/Type /Font
|
49
|
+
/Encoding /WinAnsiEncoding
|
50
|
+
/Subtype /Type1
|
51
|
+
>>
|
52
|
+
endobj
|
53
|
+
7 0 obj
|
54
|
+
<< /Length 92
|
55
|
+
>>
|
56
|
+
stream
|
57
|
+
q
|
58
|
+
|
59
|
+
BT
|
60
|
+
36 747.384 Td
|
61
|
+
/F1.0 12 Tf
|
62
|
+
[<546869732069732074656d706c61746520706167652032>] TJ
|
63
|
+
ET
|
64
|
+
|
65
|
+
Q
|
66
|
+
|
67
|
+
endstream
|
68
|
+
endobj
|
69
|
+
8 0 obj
|
70
|
+
<< /Type /Page
|
71
|
+
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
72
|
+
/Font << /F1.0 6 0 R
|
73
|
+
>>
|
74
|
+
>>
|
75
|
+
/Parent 3 0 R
|
76
|
+
/Contents 7 0 R
|
77
|
+
/MediaBox [0 0 612.0 792.0]
|
78
|
+
>>
|
79
|
+
endobj
|
80
|
+
9 0 obj
|
81
|
+
<< /Length 92
|
82
|
+
>>
|
83
|
+
stream
|
84
|
+
q
|
85
|
+
|
86
|
+
BT
|
87
|
+
36 747.384 Td
|
88
|
+
/F1.0 12 Tf
|
89
|
+
[<546869732069732074656d706c61746520706167652033>] TJ
|
90
|
+
ET
|
91
|
+
|
92
|
+
Q
|
93
|
+
|
94
|
+
endstream
|
95
|
+
endobj
|
96
|
+
10 0 obj
|
97
|
+
<< /Type /Page
|
98
|
+
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
99
|
+
/Font << /F1.0 6 0 R
|
100
|
+
>>
|
101
|
+
>>
|
102
|
+
/Parent 3 0 R
|
103
|
+
/Contents 9 0 R
|
104
|
+
/MediaBox [0 0 612.0 792.0]
|
105
|
+
>>
|
106
|
+
endobj
|
107
|
+
xref
|
108
|
+
0 11
|
109
|
+
0000000000 65535 f
|
110
|
+
0000000015 00000 n
|
111
|
+
0000000109 00000 n
|
112
|
+
0000000158 00000 n
|
113
|
+
0000000228 00000 n
|
114
|
+
0000000370 00000 n
|
115
|
+
0000000548 00000 n
|
116
|
+
0000000645 00000 n
|
117
|
+
0000000787 00000 n
|
118
|
+
0000000965 00000 n
|
119
|
+
0000001107 00000 n
|
120
|
+
trailer
|
121
|
+
<< /Size 11
|
122
|
+
/Info 1 0 R
|
123
|
+
/Root 2 0 R
|
124
|
+
>>
|
125
|
+
startxref
|
126
|
+
1286
|
127
|
+
%%EOF
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This example demonstrates the basic functionality of Prawn's bounding boxes.
|
4
4
|
# Note that top level bounding boxes are positioned relative to the margin_box.
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("bounding_boxes.pdf") do
|
9
10
|
|
@@ -27,7 +28,7 @@ Prawn::Document.generate("bounding_boxes.pdf") do
|
|
27
28
|
#
|
28
29
|
bounding_box [100,cursor], :width => 200, :height => 200 do
|
29
30
|
stroke do
|
30
|
-
|
31
|
+
circle [100,100], 100
|
31
32
|
line bounds.top_left, bounds.bottom_right
|
32
33
|
line bounds.top_right, bounds.bottom_left
|
33
34
|
end
|
@@ -40,4 +41,4 @@ Prawn::Document.generate("bounding_boxes.pdf") do
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
|
-
end
|
44
|
+
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This example demonstrates the basic functionality of Prawn's bounding boxes.
|
4
4
|
# Note that top level bounding boxes are positioned relative to the margin_box.
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("indentation.pdf") do
|
9
10
|
|
@@ -4,7 +4,8 @@
|
|
4
4
|
# can simplify calculations. See the other files in examples/bounding_box
|
5
5
|
# for more basic uses.
|
6
6
|
|
7
|
-
require
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
%w[.. example_helper]))
|
8
9
|
|
9
10
|
class Array
|
10
11
|
def combine(arr)
|
@@ -33,4 +34,4 @@ end
|
|
33
34
|
|
34
35
|
Prawn::Document.generate("russian_boxes.pdf") do |pdf|
|
35
36
|
recurse_bounding_box(pdf)
|
36
|
-
end
|
37
|
+
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This example demonstrates how nested bounding boxes work when the outer box is
|
4
4
|
# stretchy and includes several inner boxes of different sizes.
|
5
5
|
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("stretched_nesting.pdf", :page_layout => :landscape) do
|
9
10
|
|
@@ -4,7 +4,8 @@
|
|
4
4
|
# generating a new Document. Image is assumed to be pre-fit for your page
|
5
5
|
# size, and will not be rescaled.
|
6
6
|
#
|
7
|
-
require
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
%w[.. example_helper]))
|
8
9
|
|
9
10
|
img = "#{Prawn::BASEDIR}/data/images/letterhead.jpg"
|
10
11
|
|
data/examples/general/canvas.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
# Demonstrates how to enable absolute positioning in Prawn by temporarily
|
4
4
|
# removing the margin_box via Document#canvas()
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("canvas.pdf") do
|
9
10
|
canvas do
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
2
|
+
%w[.. example_helper]))
|
2
3
|
|
3
4
|
# Ex. Generate a roster of meeting attendees given a set of meetings.
|
4
5
|
# Attendees for a meeting may overflow to accross page boundaries but
|
data/examples/general/float.rb
CHANGED
data/examples/general/margin.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# This demonstrates the Prawn options for document and page margin, similar to CSS shorthand.
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
LOREM = ("Lorem ipsum dolor sit amet, consectetur adipisicing elit, "+
|
8
9
|
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "+
|
@@ -5,7 +5,8 @@
|
|
5
5
|
# its particular implementation, though some might find that interesting as
|
6
6
|
# well.
|
7
7
|
#
|
8
|
-
require
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
+
%w[.. example_helper]))
|
9
10
|
|
10
11
|
require "prawn/measurement_extensions"
|
11
12
|
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# Demonstrates how to set metadata properties via the info option
|
4
4
|
# It allows one to specify no standard properties
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate "metadata-info.pdf",
|
9
10
|
:info => {
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This demonstrates that Prawn can modify page size, margins and layout for
|
4
4
|
# each individual page, via Document#start_new_page()
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("multi-layout.pdf", :page_layout => :landscape) do |pdf|
|
9
10
|
pdf.text "This is on a landscaped page"
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This example demonstrates the use of the the outlines option for a new document
|
4
4
|
# it sets an initial outline item with a title
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate('outlines.pdf') do
|
9
10
|
text "Page 1. This is the first Chapter. "
|
@@ -4,7 +4,8 @@
|
|
4
4
|
# documents. The style used here is a bit out of date, see
|
5
5
|
# multi_page_layout.rb for a more modern example.
|
6
6
|
#
|
7
|
-
require
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
%w[.. example_helper]))
|
8
9
|
|
9
10
|
def pdf(*options)
|
10
11
|
Prawn::Document.new(*options)
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This example demonstrates how to add a "page k of n"
|
4
4
|
# template to your documents.
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("page_with_numbering.pdf") do
|
9
10
|
text "Hai"
|
@@ -11,5 +12,29 @@ Prawn::Document.generate("page_with_numbering.pdf") do
|
|
11
12
|
text "bai"
|
12
13
|
start_new_page
|
13
14
|
text "-- Hai again"
|
14
|
-
number_pages "<page> in a total of <total>", [bounds.right -
|
15
|
+
number_pages "<page> in a total of <total>", :at => [bounds.right - 100, 20],
|
16
|
+
:width => 150,
|
17
|
+
:page_filter => :all
|
18
|
+
end
|
19
|
+
|
20
|
+
Prawn::Document.generate("page_with_numbering_extra_options.pdf") do
|
21
|
+
text "Hai"
|
22
|
+
start_new_page :layout => :landscape
|
23
|
+
text "bai"
|
24
|
+
start_new_page :layout => :portrait
|
25
|
+
text "-- Hai again"
|
26
|
+
number_pages "<page> in a total of <total>", :at => [bounds.right - 150, 20],
|
27
|
+
:width => 150,
|
28
|
+
:align => :right,
|
29
|
+
:page_filter => :odd,
|
30
|
+
:start_count_at => 12,
|
31
|
+
:total_pages => 15
|
32
|
+
|
33
|
+
number_pages "<page> in a total of <total>", :at => [bounds.left + 50, 20],
|
34
|
+
:width => 150,
|
35
|
+
:align => :left,
|
36
|
+
:page_filter => :even,
|
37
|
+
:start_count_at => 13,
|
38
|
+
:total_pages => 15,
|
39
|
+
:color => "FF0000"
|
15
40
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# This sample demonstrates the use of the :template option when using #start_new_page to add a
|
4
|
+
# new page. Only one page of the template is currently imported for the template and which page of
|
5
|
+
# the pdf template is used can be specified with the :template_page option which defaults to 1.
|
6
|
+
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
%w[.. example_helper]))
|
9
|
+
|
10
|
+
filename = "#{Prawn::BASEDIR}/data/pdfs/multipage_template.pdf"
|
11
|
+
|
12
|
+
Prawn::Document.generate("page_template.pdf") do
|
13
|
+
text "This is the first page and content is brand new", :size => 18, :align => :center
|
14
|
+
start_new_page(:template => filename, :template_page => 2)
|
15
|
+
move_down 20
|
16
|
+
text "Here is some content that has been added to the page template", :size => 18, :align => :center
|
17
|
+
start_new_page(:template => filename, :template_page => 3)
|
18
|
+
move_down 20
|
19
|
+
text "Here is content that has been added to page 3 of the template", :size => 18, :align => :center
|
20
|
+
end
|
@@ -5,7 +5,8 @@
|
|
5
5
|
# they should be pretty efficient.
|
6
6
|
#
|
7
7
|
#
|
8
|
-
require
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
+
%w[.. example_helper]))
|
9
10
|
|
10
11
|
Prawn::Document.generate("repeat.pdf", :skip_page_creation => true) do
|
11
12
|
|
data/examples/general/stamp.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Demonstrate use of stamps
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
Prawn::Document.generate("stamp.pdf", :skip_page_creation => true) do
|
8
9
|
|
@@ -23,9 +24,9 @@ Prawn::Document.generate("stamp.pdf", :skip_page_creation => true) do
|
|
23
24
|
|
24
25
|
create_stamp("MyStamp") do
|
25
26
|
fill_color("ff0000")
|
26
|
-
|
27
|
+
fill_circle([0, 0], 20)
|
27
28
|
fill_color("000000")
|
28
|
-
|
29
|
+
fill_circle([10, 10], 20)
|
29
30
|
end
|
30
31
|
|
31
32
|
10.times do |i|
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This sample demonstrates the use of the :template option when generating
|
4
4
|
# a new Document. The template PDF file is imported into a new document.
|
5
5
|
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
filename = "#{Prawn::BASEDIR}/reference_pdfs/curves.pdf"
|
9
10
|
|
@@ -4,7 +4,8 @@
|
|
4
4
|
# For positioning images alongside flowing text, see the image_flow.rb
|
5
5
|
# example.
|
6
6
|
#
|
7
|
-
require
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
%w[.. example_helper]))
|
8
9
|
|
9
10
|
Prawn::Document.generate("basic_images.pdf", :page_layout => :landscape) do
|
10
11
|
stef = "#{Prawn::BASEDIR}/data/images/stef.jpg"
|
data/examples/graphics/cmyk.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Demonstrates Prawn's support for CMYK images and colors.
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
Prawn::Document.generate("cmyk.pdf", :page_layout => :landscape) do
|
8
9
|
fill_color 50, 100, 0, 0
|
data/examples/graphics/curves.rb
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
#
|
3
3
|
# Demonstrates simple curve and circle usage
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
pdf = Prawn::Document.new
|
8
9
|
pdf.move_to [100,100]
|
9
10
|
pdf.stroke_curve_to [50,50], :bounds => [[60,90], [60, 90]]
|
10
|
-
pdf.
|
11
|
-
pdf.render_file "curves.pdf"
|
11
|
+
pdf.fill_circle [200,200], 10
|
12
|
+
pdf.render_file "curves.pdf"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Demonstrate use of gradients
|
4
|
+
#
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
7
|
+
|
8
|
+
pdf = Prawn::Document.new(:margin => 0)
|
9
|
+
|
10
|
+
pdf.stroke_gradient [0, pdf.bounds.height], pdf.bounds.width, pdf.bounds.height/2, '69CD31', '0000FF'
|
11
|
+
pdf.fill_gradient [0, pdf.bounds.height], pdf.bounds.width, pdf.bounds.height/2, 'FF0000', '00FF00'
|
12
|
+
|
13
|
+
pdf.rectangle [10, pdf.bounds.height-10], 100, pdf.bounds.height-20
|
14
|
+
pdf.line_width 20
|
15
|
+
pdf.fill_and_stroke
|
16
|
+
|
17
|
+
pdf.fill_gradient [150, 250], 400, 70, 'F0FF00', '0000FF'
|
18
|
+
pdf.bounding_box [150, 250], :width => 450, :height => 150 do
|
19
|
+
pdf.text "Gradient!", :size => 80
|
20
|
+
end
|
21
|
+
|
22
|
+
pdf.render_file 'gradient.pdf'
|
23
|
+
|