prawn 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -19,7 +19,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
19
19
|
%w[.. example_helper]))
|
20
20
|
|
21
21
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
22
|
-
Prawn::Example.generate(filename) do
|
22
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
23
23
|
repeat(:all) do
|
24
24
|
draw_text "All pages", :at => bounds.top_left
|
25
25
|
end
|
@@ -32,7 +32,7 @@ Prawn::Example.generate(filename) do
|
|
32
32
|
draw_text "Only even pages", :at => [0,0]
|
33
33
|
end
|
34
34
|
|
35
|
-
repeat([1,3,7]) do
|
35
|
+
repeat([1,3,7]) do
|
36
36
|
draw_text "Only on pages 1, 3 and 7", :at => [100,0]
|
37
37
|
end
|
38
38
|
|
@@ -43,12 +43,12 @@ Prawn::Example.generate(filename) do
|
|
43
43
|
repeat(lambda { |pg| pg % 3 == 0 }) do
|
44
44
|
draw_text "Every third page", :at => [250, 20]
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
repeat(:all, :dynamic => true) do
|
48
48
|
draw_text page_number, :at => [500, 0]
|
49
49
|
end
|
50
50
|
|
51
|
-
10.times do
|
51
|
+
10.times do
|
52
52
|
start_new_page
|
53
53
|
draw_text "A wonderful page", :at => [400,400]
|
54
54
|
end
|
@@ -20,13 +20,13 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
20
20
|
%w[.. example_helper]))
|
21
21
|
|
22
22
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
23
|
-
Prawn::Example.generate(filename) do
|
23
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
24
24
|
create_stamp("approved") do
|
25
25
|
rotate(30, :origin => [-5, -5]) do
|
26
26
|
stroke_color "FF3333"
|
27
27
|
stroke_ellipse [0, 0], 29, 15
|
28
28
|
stroke_color "000000"
|
29
|
-
|
29
|
+
|
30
30
|
fill_color "993333"
|
31
31
|
font("Times-Roman") do
|
32
32
|
draw_text "Approved", :at => [-23, -3]
|
@@ -34,8 +34,8 @@ Prawn::Example.generate(filename) do
|
|
34
34
|
fill_color "000000"
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
stamp "approved"
|
39
|
-
|
39
|
+
|
40
40
|
stamp_at "approved", [200, 200]
|
41
41
|
end
|
@@ -18,14 +18,14 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
18
18
|
|
19
19
|
|
20
20
|
# Bare encryption. No password needed.
|
21
|
-
Prawn::Example.generate("bare_encryption.pdf") do
|
21
|
+
Prawn::ManualBuilder::Example.generate("bare_encryption.pdf") do
|
22
22
|
text "See, no password was asked but the document is still encrypted."
|
23
23
|
encrypt_document
|
24
24
|
end
|
25
25
|
|
26
26
|
|
27
27
|
# Simple password. All permissions granted.
|
28
|
-
Prawn::Example.generate("simple_password.pdf") do
|
28
|
+
Prawn::ManualBuilder::Example.generate("simple_password.pdf") do
|
29
29
|
text "You was asked for a password."
|
30
30
|
encrypt_document(:user_password => 'foo', :owner_password => 'bar')
|
31
31
|
end
|
@@ -20,7 +20,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
20
20
|
|
21
21
|
|
22
22
|
# User cannot print the document.
|
23
|
-
Prawn::Example.generate("cannot_print.pdf") do
|
23
|
+
Prawn::ManualBuilder::Example.generate("cannot_print.pdf") do
|
24
24
|
text "If you used the user password you won't be able to print the doc."
|
25
25
|
encrypt_document(:user_password => 'foo', :owner_password => 'bar',
|
26
26
|
:permissions => { :print_document => false })
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
|
30
30
|
# All permissions revoked and owner password set to random
|
31
|
-
Prawn::Example.generate("no_permissions.pdf") do
|
31
|
+
Prawn::ManualBuilder::Example.generate("no_permissions.pdf") do
|
32
32
|
text "You may only view this and won't be able to use the owner password."
|
33
33
|
encrypt_document(:user_password => 'foo', :owner_password => :random,
|
34
34
|
:permissions => { :print_document => false,
|
data/manual/security/security.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
6
|
%w[.. example_helper]))
|
7
7
|
|
8
|
-
Prawn::Example.generate("security.pdf", :page_size => "FOLIO") do
|
9
|
-
|
8
|
+
Prawn::ManualBuilder::Example.generate("security.pdf", :page_size => "FOLIO") do
|
9
|
+
|
10
10
|
package "security" do |p|
|
11
|
-
|
11
|
+
|
12
12
|
p.example "encryption", :eval_source => false, :full_source => true
|
13
13
|
p.example "permissions", :eval_source => false, :full_source => true
|
14
|
-
|
14
|
+
|
15
15
|
p.intro do
|
16
16
|
prose("Security lets you control who can read the document by defining a password.
|
17
17
|
|
@@ -23,6 +23,6 @@ Prawn::Example.generate("security.pdf", :page_size => "FOLIO") do
|
|
23
23
|
"How to set a owner password that bypass the document permissions"
|
24
24
|
)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
end
|
28
28
|
end
|
data/manual/table/basic_block.rb
CHANGED
@@ -33,21 +33,21 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
33
33
|
%w[.. example_helper]))
|
34
34
|
|
35
35
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
36
|
-
Prawn::Example.generate(filename) do
|
36
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
37
37
|
data = [ ["Header", "A " * 5, "B"],
|
38
38
|
["Data row", "C", "D " * 5],
|
39
39
|
["Another data row", "E", "F"]]
|
40
|
-
|
40
|
+
|
41
41
|
table(data) do
|
42
42
|
cells.padding = 12
|
43
43
|
cells.borders = []
|
44
|
-
|
44
|
+
|
45
45
|
row(0).borders = [:bottom]
|
46
46
|
row(0).border_width = 2
|
47
47
|
row(0).font_style = :bold
|
48
|
-
|
48
|
+
|
49
49
|
columns(0..1).borders = [:right]
|
50
|
-
|
50
|
+
|
51
51
|
row(0).columns(0..1).borders = [:bottom, :right]
|
52
52
|
end
|
53
53
|
end
|
@@ -13,7 +13,7 @@ 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
|
table([["foo", "bar", "baz"]] * 40) do |t|
|
18
18
|
t.cells.border_width = 1
|
19
19
|
t.before_rendering_page do |page|
|
@@ -9,16 +9,16 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
9
9
|
%w[.. example_helper]))
|
10
10
|
|
11
11
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
12
|
-
Prawn::Example.generate(filename) do
|
12
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
13
13
|
data = [ ["Look at how the cell border lines can be mixed", "", ""],
|
14
14
|
["dotted top border", "", ""],
|
15
15
|
["solid right border", "", ""],
|
16
16
|
["dotted bottom border", "", ""],
|
17
17
|
["dashed left border", "", ""]
|
18
18
|
]
|
19
|
-
|
19
|
+
|
20
20
|
text "Cell :border_lines => [:dotted, :solid, :dotted, :dashed]"
|
21
|
-
|
22
|
-
table(data, :cell_style =>
|
21
|
+
|
22
|
+
table(data, :cell_style =>
|
23
23
|
{ :border_lines => [:dotted, :solid, :dotted, :dashed] })
|
24
24
|
end
|
@@ -12,20 +12,20 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
12
12
|
%w[.. example_helper]))
|
13
13
|
|
14
14
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
15
|
-
Prawn::Example.generate(filename) do
|
15
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
16
16
|
data = [ ["Look at how the cells will look when styled", "", ""],
|
17
17
|
["They probably won't look the same", "", ""]
|
18
18
|
]
|
19
|
-
|
19
|
+
|
20
20
|
{ :borders => [:top, :left],
|
21
21
|
:border_width => 3,
|
22
22
|
:border_color => "FF0000"}.each do |property, value|
|
23
|
-
|
23
|
+
|
24
24
|
text "Cell #{property}: #{value.inspect}"
|
25
25
|
table(data, :cell_style => {property => value})
|
26
26
|
move_down 20
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
text "Cell background_color: FFFFCC"
|
30
30
|
table(data, :cell_style => {:background_color => "FFFFCC"})
|
31
31
|
end
|
@@ -14,17 +14,17 @@ 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
|
data = [ ["Look at how the cells will look when styled", "", ""],
|
19
19
|
["They probably won't look the same", "", ""]
|
20
20
|
]
|
21
|
-
|
21
|
+
|
22
22
|
{:width => 160, :height => 50, :padding => 12}.each do |property, value|
|
23
23
|
text "Cell's #{property}: #{value}"
|
24
24
|
table(data, :cell_style => {property => value})
|
25
25
|
move_down 20
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
text "Padding can also be set with an array: [0, 0, 0, 30]"
|
29
29
|
table(data, :cell_style => {:padding => [0, 0, 0, 30]})
|
30
30
|
end
|
data/manual/table/cell_text.rb
CHANGED
@@ -14,25 +14,25 @@ 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
|
data = [ ["Look at how the cells will look when styled", "", ""],
|
19
19
|
["They probably won't look the same", "", ""]
|
20
20
|
]
|
21
|
-
|
21
|
+
|
22
22
|
table data, :cell_style => { :font => "Times-Roman", :font_style => :italic }
|
23
23
|
move_down 20
|
24
|
-
|
24
|
+
|
25
25
|
table data, :cell_style => { :size => 18, :text_color => "346842" }
|
26
26
|
move_down 20
|
27
|
-
|
27
|
+
|
28
28
|
table [["Just <font size='18'>some</font> <b><i>inline</i></b>", "", ""],
|
29
29
|
["<color rgb='FF00FF'>styles</color> being applied here", "", ""]],
|
30
30
|
:cell_style => { :inline_format => true }
|
31
31
|
move_down 20
|
32
|
-
|
32
|
+
|
33
33
|
table [["1", "2", "3", "rotate"]], :cell_style => { :rotate => 30 }
|
34
34
|
move_down 20
|
35
|
-
|
35
|
+
|
36
36
|
table data, :cell_style => { :overflow => :shrink_to_fit, :min_font_size => 8,
|
37
37
|
:width => 60, :height => 30 }
|
38
38
|
end
|
@@ -12,19 +12,19 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
12
12
|
%w[.. example_helper]))
|
13
13
|
|
14
14
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
15
|
-
Prawn::Example.generate(filename) do
|
15
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
16
16
|
data = [ ["this is not quite as long as the others",
|
17
17
|
"here we have a line that is long but with smaller words",
|
18
18
|
"this is so very looooooooooooooooooooooooooooooong"] ]
|
19
|
-
|
19
|
+
|
20
20
|
text "Prawn trying to guess the column widths"
|
21
21
|
table(data)
|
22
22
|
move_down 20
|
23
|
-
|
23
|
+
|
24
24
|
text "Manually setting all the column widths"
|
25
25
|
table(data, :column_widths => [100, 200, 240])
|
26
26
|
move_down 20
|
27
|
-
|
27
|
+
|
28
28
|
text "Setting only the last column width"
|
29
29
|
table(data, :column_widths => {2 => 240})
|
30
30
|
end
|
@@ -21,16 +21,16 @@ 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
|
cell_1 = make_cell(:content => "this row content comes directly ")
|
26
26
|
cell_2 = make_cell(:content => "from cell objects")
|
27
|
-
|
27
|
+
|
28
28
|
two_dimensional_array = [ ["..."], ["subtable from an array"], ["..."] ]
|
29
|
-
|
29
|
+
|
30
30
|
my_table = make_table([ ["..."], ["subtable from another table"], ["..."] ])
|
31
|
-
|
31
|
+
|
32
32
|
image_path = "#{Prawn::DATADIR}/images/stef.jpg"
|
33
|
-
|
33
|
+
|
34
34
|
table([ ["just a regular row", "", "", "blah blah blah"],
|
35
35
|
[cell_1, cell_2, "", ""],
|
36
36
|
["", "", two_dimensional_array, ""],
|
data/manual/table/creation.rb
CHANGED
@@ -15,12 +15,12 @@ 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
|
t = make_table([ ["this is the first row"],
|
20
20
|
["this is the second row"] ])
|
21
21
|
t.draw
|
22
22
|
move_down 20
|
23
|
-
|
23
|
+
|
24
24
|
table([ ["short", "short", "loooooooooooooooooooong"],
|
25
25
|
["short", "loooooooooooooooooooong", "short"],
|
26
26
|
["loooooooooooooooooooong", "short", "short"] ])
|
data/manual/table/filtering.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Another way to reduce the number of cells is to <code>filter</code> the table.
|
4
4
|
#
|
5
5
|
# <code>filter</code> is just like <code>Enumerable#select</code>. Pass it a
|
6
|
-
# block and it will iterate through the cells returning a new
|
6
|
+
# block and it will iterate through the cells returning a new
|
7
7
|
# <code>Prawn::Table::Cells</code> instance containing only those cells for
|
8
8
|
# which the block was not false.
|
9
9
|
#
|
@@ -11,26 +11,26 @@ 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
|
data = [ ["Item", "Jan Sales", "Feb Sales"],
|
16
16
|
["Oven", 17, 89],
|
17
17
|
["Fridge", 62, 30],
|
18
18
|
["Microwave", 71, 47]
|
19
19
|
]
|
20
|
-
|
20
|
+
|
21
21
|
table(data) do
|
22
22
|
values = cells.columns(1..-1).rows(1..-1)
|
23
|
-
|
23
|
+
|
24
24
|
bad_sales = values.filter do |cell|
|
25
25
|
cell.content.to_i < 40
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
bad_sales.background_color = "FFAAAA"
|
29
29
|
|
30
30
|
good_sales = values.filter do |cell|
|
31
31
|
cell.content.to_i > 70
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
good_sales.background_color = "AAFFAA"
|
35
35
|
end
|
36
36
|
end
|
@@ -9,9 +9,9 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
9
9
|
%w[.. example_helper]))
|
10
10
|
|
11
11
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
12
|
-
Prawn::Example.generate(filename) do
|
12
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
13
13
|
data = [["This row should be repeated on every new page"]]
|
14
14
|
data += [["..."]] * 30
|
15
|
-
|
15
|
+
|
16
16
|
table(data, :header => true)
|
17
17
|
end
|
data/manual/table/image_cells.rb
CHANGED
@@ -16,7 +16,7 @@ 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
|
image = "#{Prawn::DATADIR}/images/prawn.png"
|
21
21
|
|
22
22
|
table [
|
data/manual/table/position.rb
CHANGED
@@ -9,7 +9,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
9
9
|
%w[.. example_helper]))
|
10
10
|
|
11
11
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
12
|
-
Prawn::Example.generate(filename) do
|
12
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
13
13
|
data = [["The quick brown fox jumped over the lazy dogs."]] * 2
|
14
14
|
|
15
15
|
text "Left:"
|
data/manual/table/row_colors.rb
CHANGED
@@ -10,11 +10,11 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
10
10
|
%w[.. example_helper]))
|
11
11
|
|
12
12
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
13
|
-
Prawn::Example.generate(filename) do
|
13
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
14
14
|
data = [["This row should have one color"],
|
15
15
|
["And this row should have another"]]
|
16
|
-
|
16
|
+
|
17
17
|
data += [["..."]] * 10
|
18
|
-
|
18
|
+
|
19
19
|
table(data, :row_colors => ["F0F0F0", "FFFFCC"])
|
20
20
|
end
|
data/manual/table/span.rb
CHANGED
@@ -20,7 +20,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),
|
|
20
20
|
%w[.. example_helper]))
|
21
21
|
|
22
22
|
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
23
|
-
Prawn::Example.generate(filename) do
|
23
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
24
24
|
table([
|
25
25
|
["A", {:content => "2x1", :colspan => 2}, "B"],
|
26
26
|
[{:content => "1x2", :rowspan => 2}, "C", "D", "E"],
|
data/manual/table/style.rb
CHANGED
@@ -11,11 +11,11 @@ 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
|
table([[""] * 8] * 8) do
|
16
16
|
cells.style(:width => 24, :height => 24)
|
17
|
-
|
18
|
-
cells.style do |c|
|
17
|
+
|
18
|
+
cells.style do |c|
|
19
19
|
c.background_color = ((c.row + c.column) % 2).zero? ? '000000' : 'ffffff'
|
20
20
|
end
|
21
21
|
end
|
data/manual/table/table.rb
CHANGED
@@ -5,17 +5,17 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
6
|
%w[.. example_helper]))
|
7
7
|
|
8
|
-
Prawn::Example.generate("table.pdf", :page_size => "FOLIO") do
|
9
|
-
|
8
|
+
Prawn::ManualBuilder::Example.generate("table.pdf", :page_size => "FOLIO") do
|
9
|
+
|
10
10
|
package "table" do |p|
|
11
|
-
|
11
|
+
|
12
12
|
p.section "Basics" do |s|
|
13
13
|
s.example "creation"
|
14
14
|
s.example "content_and_subtables"
|
15
15
|
s.example "flow_and_header"
|
16
16
|
s.example "position"
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
p.section "Styling" do |s|
|
20
20
|
s.example "column_widths"
|
21
21
|
s.example "width"
|
@@ -28,13 +28,13 @@ Prawn::Example.generate("table.pdf", :page_size => "FOLIO") do
|
|
28
28
|
s.example "span"
|
29
29
|
s.example "before_rendering_page"
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
p.section "Initializer Block" do |s|
|
33
33
|
s.example "basic_block"
|
34
34
|
s.example "filtering"
|
35
35
|
s.example "style"
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
p.intro do
|
39
39
|
prose("Prawn comes with table support out of the box. Tables can be styled in whatever way you see fit. The whole table, rows, columns and cells can be styled independently from each other.
|
40
40
|
|
@@ -47,6 +47,6 @@ Prawn::Example.generate("table.pdf", :page_size => "FOLIO") do
|
|
47
47
|
"How to use initializer blocks to style only specific portions of the table"
|
48
48
|
)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
end
|
52
52
|
end
|