prawn 0.13.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +10 -0
- data/GPLv2 +20 -21
- data/Gemfile +3 -16
- data/Rakefile +17 -39
- data/lib/prawn/document/bounding_box.rb +85 -42
- data/lib/prawn/document/column_box.rb +21 -11
- data/lib/prawn/document/internals.rb +40 -147
- data/lib/prawn/document/span.rb +25 -17
- data/lib/prawn/document.rb +286 -245
- data/lib/prawn/encoding.rb +68 -101
- data/lib/prawn/errors.rb +47 -43
- data/lib/prawn/font.rb +204 -155
- data/lib/prawn/font_metric_cache.rb +25 -21
- data/lib/prawn/fonts/afm.rb +292 -0
- data/lib/prawn/{font → fonts}/dfont.rb +7 -13
- data/lib/prawn/fonts/otf.rb +11 -0
- data/lib/prawn/fonts/ttc.rb +36 -0
- data/lib/prawn/{font → fonts}/ttf.rb +142 -80
- data/lib/prawn/graphics/blend_mode.rb +65 -0
- data/lib/prawn/graphics/cap_style.rb +6 -5
- data/lib/prawn/graphics/color.rb +47 -44
- data/lib/prawn/graphics/dash.rb +30 -13
- data/lib/prawn/graphics/join_style.rb +13 -6
- data/lib/prawn/graphics/patterns.rb +221 -90
- data/lib/prawn/graphics/transformation.rb +21 -12
- data/lib/prawn/graphics/transparency.rb +21 -17
- data/lib/prawn/graphics.rb +155 -128
- data/lib/prawn/{layout/grid.rb → grid.rb} +110 -47
- data/lib/prawn/image_handler.rb +16 -2
- data/lib/prawn/images/image.rb +4 -2
- data/lib/prawn/images/jpg.rb +39 -30
- data/lib/prawn/images/png.rb +132 -169
- data/lib/prawn/images.rb +70 -62
- data/lib/prawn/measurement_extensions.rb +15 -10
- data/lib/prawn/measurements.rb +22 -23
- data/lib/prawn/outline.rb +301 -13
- data/lib/prawn/repeater.rb +19 -17
- data/lib/prawn/security/arcfour.rb +54 -0
- data/lib/prawn/security.rb +108 -86
- data/lib/prawn/soft_mask.rb +40 -41
- data/lib/prawn/stamp.rb +29 -12
- data/lib/prawn/text/box.rb +27 -29
- data/lib/prawn/text/formatted/arranger.rb +110 -67
- data/lib/prawn/text/formatted/box.rb +233 -165
- data/lib/prawn/text/formatted/fragment.rb +27 -27
- data/lib/prawn/text/formatted/line_wrap.rb +137 -97
- data/lib/prawn/text/formatted/parser.rb +149 -127
- data/lib/prawn/text/formatted/wrap.rb +57 -37
- data/lib/prawn/text/formatted.rb +6 -4
- data/lib/prawn/text.rb +105 -73
- data/lib/prawn/transformation_stack.rb +44 -0
- data/lib/prawn/utilities.rb +11 -21
- data/lib/prawn/version.rb +5 -0
- data/lib/prawn/view.rb +101 -0
- data/lib/prawn.rb +42 -68
- data/{data/images/fractal.jpg → manual/absolute_position.pdf} +0 -0
- data/manual/basic_concepts/adding_pages.rb +9 -10
- data/manual/basic_concepts/basic_concepts.rb +33 -24
- data/manual/basic_concepts/creation.rb +10 -11
- data/manual/basic_concepts/cursor.rb +9 -10
- data/manual/basic_concepts/measurement.rb +10 -11
- data/manual/basic_concepts/origin.rb +8 -9
- data/manual/basic_concepts/other_cursor_helpers.rb +17 -18
- data/manual/basic_concepts/view.rb +48 -0
- data/manual/bounding_box/bounding_box.rb +31 -29
- data/manual/bounding_box/bounds.rb +17 -18
- data/manual/bounding_box/canvas.rb +8 -9
- data/manual/bounding_box/creation.rb +8 -9
- data/manual/bounding_box/indentation.rb +22 -23
- data/manual/bounding_box/nesting.rb +32 -25
- data/manual/bounding_box/russian_boxes.rb +19 -19
- data/manual/bounding_box/stretchy.rb +18 -20
- data/manual/contents.rb +35 -0
- data/manual/cover.rb +43 -0
- data/manual/document_and_page_options/background.rb +16 -14
- data/manual/document_and_page_options/document_and_page_options.rb +26 -23
- data/manual/document_and_page_options/metadata.rb +21 -19
- data/manual/document_and_page_options/page_margins.rb +20 -22
- data/manual/document_and_page_options/page_size.rb +15 -15
- data/manual/document_and_page_options/print_scaling.rb +23 -0
- data/manual/example_helper.rb +5 -408
- data/manual/graphics/blend_mode.rb +52 -0
- data/manual/graphics/circle_and_ellipse.rb +8 -9
- data/manual/graphics/color.rb +11 -13
- data/manual/graphics/common_lines.rb +13 -12
- data/manual/graphics/fill_and_stroke.rb +10 -11
- data/manual/graphics/fill_rules.rb +13 -12
- data/manual/graphics/gradients.rb +28 -22
- data/manual/graphics/graphics.rb +52 -46
- data/manual/graphics/helper.rb +20 -10
- data/manual/graphics/line_width.rb +13 -12
- data/manual/graphics/lines_and_curves.rb +13 -14
- data/manual/graphics/polygon.rb +10 -12
- data/manual/graphics/rectangle.rb +7 -8
- data/manual/graphics/rotate.rb +9 -12
- data/manual/graphics/scale.rb +19 -18
- data/manual/graphics/soft_masks.rb +5 -7
- data/manual/graphics/stroke_cap.rb +10 -11
- data/manual/graphics/stroke_dash.rb +16 -17
- data/manual/graphics/stroke_join.rb +10 -11
- data/manual/graphics/translate.rb +13 -13
- data/manual/graphics/transparency.rb +11 -13
- data/manual/{manual/how_to_read_this_manual.rb → how_to_read_this_manual.rb} +23 -25
- data/manual/images/absolute_position.rb +9 -10
- data/manual/images/fit.rb +9 -10
- data/manual/images/horizontal.rb +13 -14
- data/manual/images/images.rb +31 -30
- data/manual/images/plain_image.rb +6 -7
- data/manual/images/scale.rb +12 -13
- data/manual/images/vertical.rb +19 -17
- data/manual/images/width_and_height.rb +13 -14
- data/manual/layout/boxes.rb +14 -15
- data/manual/layout/content.rb +12 -13
- data/manual/layout/layout.rb +19 -20
- data/manual/layout/simple_grid.rb +8 -9
- data/manual/outline/add_subsection_to.rb +26 -27
- data/manual/outline/insert_section_after.rb +19 -20
- data/manual/outline/outline.rb +23 -22
- data/manual/outline/sections_and_pages.rb +24 -25
- data/manual/repeatable_content/alternate_page_numbering.rb +36 -0
- data/manual/repeatable_content/page_numbering.rb +20 -19
- data/manual/repeatable_content/repeatable_content.rb +26 -22
- data/manual/repeatable_content/repeater.rb +18 -19
- data/manual/repeatable_content/stamp.rb +18 -19
- data/manual/security/encryption.rb +8 -11
- data/manual/security/permissions.rb +20 -15
- data/manual/security/security.rb +20 -20
- data/manual/table.rb +16 -0
- data/manual/text/alignment.rb +17 -18
- data/manual/text/color.rb +13 -13
- data/manual/text/column_box.rb +10 -12
- data/manual/text/fallback_fonts.rb +29 -25
- data/manual/text/font.rb +17 -18
- data/manual/text/font_size.rb +21 -22
- data/manual/text/font_style.rb +12 -10
- data/manual/text/formatted_callbacks.rb +36 -26
- data/manual/text/formatted_text.rb +41 -34
- data/manual/text/free_flowing_text.rb +28 -29
- data/manual/text/inline.rb +23 -26
- data/manual/text/kerning_and_character_spacing.rb +20 -21
- data/manual/text/leading.rb +10 -11
- data/manual/text/line_wrapping.rb +40 -21
- data/manual/text/paragraph_indentation.rb +17 -12
- data/manual/text/positioned_text.rb +19 -20
- data/manual/text/registering_families.rb +33 -30
- data/manual/text/rendering_and_color.rb +11 -12
- data/manual/text/right_to_left_text.rb +31 -20
- data/manual/text/rotation.rb +36 -27
- data/manual/text/single_usage.rb +13 -14
- data/manual/text/text.rb +62 -62
- data/manual/text/text_box_excess.rb +22 -19
- data/manual/text/text_box_extensions.rb +21 -18
- data/manual/text/text_box_overflow.rb +28 -21
- data/manual/text/utf8.rb +16 -17
- data/manual/text/win_ansi_charset.rb +29 -26
- data/prawn.gemspec +45 -43
- data/spec/extensions/encoding_helpers.rb +4 -3
- data/spec/prawn/document/bounding_box_spec.rb +550 -0
- data/spec/prawn/document/column_box_spec.rb +75 -0
- data/spec/prawn/document/security_spec.rb +176 -0
- data/spec/prawn/document_annotations_spec.rb +76 -0
- data/spec/prawn/document_destinations_spec.rb +15 -0
- data/spec/prawn/document_grid_spec.rb +99 -0
- data/spec/prawn/document_reference_spec.rb +27 -0
- data/spec/prawn/document_span_spec.rb +44 -0
- data/spec/prawn/document_spec.rb +805 -0
- data/spec/prawn/font_metric_cache_spec.rb +54 -0
- data/spec/prawn/font_spec.rb +544 -0
- data/spec/prawn/graphics/blend_mode_spec.rb +63 -0
- data/spec/prawn/graphics/transparency_spec.rb +81 -0
- data/spec/prawn/graphics_spec.rb +872 -0
- data/spec/prawn/graphics_stroke_styles_spec.rb +229 -0
- data/spec/prawn/image_handler_spec.rb +53 -0
- data/spec/prawn/images/jpg_spec.rb +20 -0
- data/spec/prawn/images/png_spec.rb +283 -0
- data/spec/prawn/images_spec.rb +229 -0
- data/spec/prawn/measurements_extensions_spec.rb +24 -0
- data/spec/prawn/outline_spec.rb +512 -0
- data/spec/prawn/repeater_spec.rb +166 -0
- data/spec/prawn/soft_mask_spec.rb +74 -0
- data/spec/prawn/stamp_spec.rb +173 -0
- data/spec/prawn/text/box_spec.rb +1110 -0
- data/spec/prawn/text/formatted/arranger_spec.rb +466 -0
- data/spec/prawn/text/formatted/box_spec.rb +849 -0
- data/spec/prawn/text/formatted/fragment_spec.rb +343 -0
- data/spec/prawn/text/formatted/line_wrap_spec.rb +495 -0
- data/spec/prawn/text/formatted/parser_spec.rb +697 -0
- data/spec/prawn/text_draw_text_spec.rb +150 -0
- data/spec/prawn/text_rendering_mode_spec.rb +48 -0
- data/spec/prawn/text_spacing_spec.rb +95 -0
- data/spec/prawn/text_spec.rb +603 -0
- data/spec/prawn/text_with_inline_formatting_spec.rb +35 -0
- data/spec/prawn/transformation_stack_spec.rb +66 -0
- data/spec/prawn/view_spec.rb +63 -0
- data/spec/prawn_manual_spec.rb +35 -0
- data/spec/spec_helper.rb +22 -21
- data.tar.gz.sig +0 -0
- metadata +168 -307
- metadata.gz.sig +0 -0
- data/README.md +0 -109
- data/data/encodings/win_ansi.txt +0 -29
- data/data/images/16bit.alpha +0 -0
- data/data/images/16bit.dat +0 -0
- data/data/images/16bit.png +0 -0
- data/data/images/arrow.png +0 -0
- data/data/images/arrow2.png +0 -0
- data/data/images/barcode_issue.png +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.dat +0 -0
- data/data/images/dice.png +0 -0
- data/data/images/dice_interlaced.png +0 -0
- data/data/images/indexed_color.dat +0 -0
- data/data/images/indexed_color.png +0 -0
- data/data/images/letterhead.jpg +0 -0
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.dat +0 -0
- data/data/images/page_white_text.png +0 -0
- data/data/images/pigs.jpg +0 -0
- data/data/images/prawn.png +0 -0
- data/data/images/ruport.png +0 -0
- data/data/images/ruport_data.dat +0 -0
- data/data/images/ruport_transparent.png +0 -0
- data/data/images/ruport_type0.png +0 -0
- data/data/images/stef.jpg +0 -0
- data/data/images/tru256.bmp +0 -0
- data/data/images/web-links.dat +0 -1
- data/data/images/web-links.png +0 -0
- data/data/pdfs/complex_template.pdf +0 -0
- data/data/pdfs/contains_ttf_font.pdf +0 -0
- data/data/pdfs/encrypted.pdf +0 -0
- data/data/pdfs/form.pdf +1 -819
- data/data/pdfs/hexagon.pdf +0 -61
- data/data/pdfs/indirect_reference.pdf +0 -86
- data/data/pdfs/multipage_template.pdf +0 -127
- data/data/pdfs/nested_pages.pdf +0 -118
- data/data/pdfs/page_without_mediabox.pdf +0 -193
- data/data/pdfs/resources_as_indirect_object.pdf +0 -83
- data/data/pdfs/two_hexagons.pdf +0 -90
- data/data/pdfs/version_1_6.pdf +0 -61
- data/data/shift_jis_text.txt +0 -1
- data/lib/pdf/core/annotations.rb +0 -60
- data/lib/pdf/core/byte_string.rb +0 -9
- data/lib/pdf/core/destinations.rb +0 -90
- data/lib/pdf/core/document_state.rb +0 -78
- data/lib/pdf/core/filter_list.rb +0 -51
- data/lib/pdf/core/filters.rb +0 -36
- data/lib/pdf/core/graphics_state.rb +0 -68
- data/lib/pdf/core/literal_string.rb +0 -16
- data/lib/pdf/core/name_tree.rb +0 -177
- data/lib/pdf/core/object_store.rb +0 -320
- data/lib/pdf/core/outline.rb +0 -315
- data/lib/pdf/core/page.rb +0 -212
- data/lib/pdf/core/page_geometry.rb +0 -126
- data/lib/pdf/core/pdf_object.rb +0 -124
- data/lib/pdf/core/reference.rb +0 -103
- data/lib/pdf/core/stream.rb +0 -98
- data/lib/pdf/core/text.rb +0 -275
- data/lib/pdf/core.rb +0 -35
- data/lib/prawn/compatibility.rb +0 -91
- data/lib/prawn/document/graphics_state.rb +0 -73
- data/lib/prawn/document/snapshot.rb +0 -89
- data/lib/prawn/font/afm.rb +0 -203
- data/lib/prawn/layout.rb +0 -20
- data/lib/prawn/table/cell/image.rb +0 -70
- data/lib/prawn/table/cell/in_table.rb +0 -27
- data/lib/prawn/table/cell/span_dummy.rb +0 -92
- data/lib/prawn/table/cell/subtable.rb +0 -65
- data/lib/prawn/table/cell/text.rb +0 -153
- data/lib/prawn/table/cell.rb +0 -770
- data/lib/prawn/table/cells.rb +0 -295
- data/lib/prawn/table.rb +0 -643
- data/manual/example_file.rb +0 -116
- data/manual/example_package.rb +0 -53
- data/manual/example_section.rb +0 -46
- data/manual/manual/cover.rb +0 -35
- data/manual/manual/foreword.rb +0 -85
- data/manual/manual/manual.rb +0 -35
- data/manual/syntax_highlight.rb +0 -52
- data/manual/table/basic_block.rb +0 -53
- data/manual/table/before_rendering_page.rb +0 -26
- data/manual/table/cell_border_lines.rb +0 -24
- data/manual/table/cell_borders_and_bg.rb +0 -31
- data/manual/table/cell_dimensions.rb +0 -30
- data/manual/table/cell_text.rb +0 -38
- data/manual/table/column_widths.rb +0 -30
- data/manual/table/content_and_subtables.rb +0 -39
- data/manual/table/creation.rb +0 -27
- data/manual/table/filtering.rb +0 -36
- data/manual/table/flow_and_header.rb +0 -17
- data/manual/table/image_cells.rb +0 -33
- data/manual/table/position.rb +0 -29
- data/manual/table/row_colors.rb +0 -20
- data/manual/table/span.rb +0 -30
- data/manual/table/style.rb +0 -22
- data/manual/table/table.rb +0 -52
- data/manual/table/width.rb +0 -27
- data/manual/templates/full_template.rb +0 -25
- data/manual/templates/page_template.rb +0 -48
- data/manual/templates/templates.rb +0 -27
- data/manual/text/group.rb +0 -29
- data/spec/acceptance/png.rb +0 -23
- data/spec/annotations_spec.rb +0 -74
- data/spec/bounding_box_spec.rb +0 -493
- data/spec/cell_spec.rb +0 -628
- data/spec/column_box_spec.rb +0 -33
- data/spec/destinations_spec.rb +0 -15
- data/spec/document_spec.rb +0 -761
- data/spec/extensions/mocha.rb +0 -44
- data/spec/filters_spec.rb +0 -34
- data/spec/font_metric_cache_spec.rb +0 -52
- data/spec/font_spec.rb +0 -464
- data/spec/formatted_text_arranger_spec.rb +0 -421
- data/spec/formatted_text_box_spec.rb +0 -650
- data/spec/formatted_text_fragment_spec.rb +0 -298
- data/spec/graphics_spec.rb +0 -651
- data/spec/grid_spec.rb +0 -85
- data/spec/image_handler_spec.rb +0 -42
- data/spec/images_spec.rb +0 -157
- data/spec/inline_formatted_text_parser_spec.rb +0 -564
- data/spec/jpg_spec.rb +0 -25
- data/spec/line_wrap_spec.rb +0 -333
- data/spec/measurement_units_spec.rb +0 -23
- data/spec/name_tree_spec.rb +0 -112
- data/spec/object_store_spec.rb +0 -170
- data/spec/outline_spec.rb +0 -448
- data/spec/pdf_object_spec.rb +0 -172
- data/spec/png_spec.rb +0 -240
- data/spec/reference_spec.rb +0 -82
- data/spec/repeater_spec.rb +0 -158
- data/spec/security_spec.rb +0 -158
- data/spec/snapshot_spec.rb +0 -186
- data/spec/soft_mask_spec.rb +0 -117
- data/spec/span_spec.rb +0 -44
- data/spec/stamp_spec.rb +0 -158
- data/spec/stream_spec.rb +0 -58
- data/spec/stroke_styles_spec.rb +0 -211
- data/spec/table/span_dummy_spec.rb +0 -17
- data/spec/table_spec.rb +0 -1355
- data/spec/template_spec.rb +0 -351
- data/spec/text_at_spec.rb +0 -130
- data/spec/text_box_spec.rb +0 -1030
- data/spec/text_rendering_mode_spec.rb +0 -45
- data/spec/text_spacing_spec.rb +0 -93
- data/spec/text_spec.rb +0 -425
- data/spec/text_with_inline_formatting_spec.rb +0 -35
- data/spec/transparency_spec.rb +0 -89
@@ -1,39 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# There are five kinds of objects which can be put in table cells:
|
4
|
-
# 1. String: produces a text cell (the most common usage)
|
5
|
-
# 2. <code>Prawn::Table::Cell</code>
|
6
|
-
# 3. <code>Prawn::Table</code>
|
7
|
-
# 4. Array
|
8
|
-
# 5. Images
|
9
|
-
#
|
10
|
-
# Whenever a table or an array is provided as a cell, a subtable will be created
|
11
|
-
# (a table within a cell).
|
12
|
-
#
|
13
|
-
# If you'd like to provide a cell or table directly, the best way is to
|
14
|
-
# use the <code>make_cell</code> and <code>make_table</code> methods as they
|
15
|
-
# don't call <code>draw</code> on the created object.
|
16
|
-
#
|
17
|
-
# To insert an image just provide a hash with an with an <code>:image</code> key
|
18
|
-
# pointing to the image path.
|
19
|
-
#
|
20
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
21
|
-
%w[.. example_helper]))
|
22
|
-
|
23
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
24
|
-
Prawn::Example.generate(filename) do
|
25
|
-
cell_1 = make_cell(:content => "this row content comes directly ")
|
26
|
-
cell_2 = make_cell(:content => "from cell objects")
|
27
|
-
|
28
|
-
two_dimensional_array = [ ["..."], ["subtable from an array"], ["..."] ]
|
29
|
-
|
30
|
-
my_table = make_table([ ["..."], ["subtable from another table"], ["..."] ])
|
31
|
-
|
32
|
-
image_path = "#{Prawn::DATADIR}/images/stef.jpg"
|
33
|
-
|
34
|
-
table([ ["just a regular row", "", "", "blah blah blah"],
|
35
|
-
[cell_1, cell_2, "", ""],
|
36
|
-
["", "", two_dimensional_array, ""],
|
37
|
-
["just another regular row", "", "", ""],
|
38
|
-
[{:image => image_path}, "", my_table, ""]])
|
39
|
-
end
|
data/manual/table/creation.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Creating tables with Prawn is fairly easy. There are two methods that will
|
4
|
-
# create tables for us <code>table</code> and <code>make_table</code>.
|
5
|
-
#
|
6
|
-
# Both are wrappers that create a new <code>Prawn::Table</code> object. The
|
7
|
-
# difference is that <code>table</code> calls the <code>draw</code> method
|
8
|
-
# after creating the table and <code>make_table</code> only returns the created
|
9
|
-
# table, so you have to call the <code>draw</code> method yourself.
|
10
|
-
#
|
11
|
-
# The most simple table can be created by providing only an array of arrays
|
12
|
-
# containing your data where each inner array represents one row.
|
13
|
-
#
|
14
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
15
|
-
%w[.. example_helper]))
|
16
|
-
|
17
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
18
|
-
Prawn::Example.generate(filename) do
|
19
|
-
t = make_table([ ["this is the first row"],
|
20
|
-
["this is the second row"] ])
|
21
|
-
t.draw
|
22
|
-
move_down 20
|
23
|
-
|
24
|
-
table([ ["short", "short", "loooooooooooooooooooong"],
|
25
|
-
["short", "loooooooooooooooooooong", "short"],
|
26
|
-
["loooooooooooooooooooong", "short", "short"] ])
|
27
|
-
end
|
data/manual/table/filtering.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Another way to reduce the number of cells is to <code>filter</code> the table.
|
4
|
-
#
|
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
|
7
|
-
# <code>Prawn::Table::Cells</code> instance containing only those cells for
|
8
|
-
# which the block was not false.
|
9
|
-
#
|
10
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
11
|
-
%w[.. example_helper]))
|
12
|
-
|
13
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
14
|
-
Prawn::Example.generate(filename) do
|
15
|
-
data = [ ["Item", "Jan Sales", "Feb Sales"],
|
16
|
-
["Oven", 17, 89],
|
17
|
-
["Fridge", 62, 30],
|
18
|
-
["Microwave", 71, 47]
|
19
|
-
]
|
20
|
-
|
21
|
-
table(data) do
|
22
|
-
values = cells.columns(1..-1).rows(1..-1)
|
23
|
-
|
24
|
-
bad_sales = values.filter do |cell|
|
25
|
-
cell.content.to_i < 40
|
26
|
-
end
|
27
|
-
|
28
|
-
bad_sales.background_color = "FFAAAA"
|
29
|
-
|
30
|
-
good_sales = values.filter do |cell|
|
31
|
-
cell.content.to_i > 70
|
32
|
-
end
|
33
|
-
|
34
|
-
good_sales.background_color = "AAFFAA"
|
35
|
-
end
|
36
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# If the table cannot fit on the current page it will flow to the next page just
|
4
|
-
# like free flowing text. If you would like to have the first row treated as a
|
5
|
-
# header which will be repeated on subsequent pages set the <code>:header</code>
|
6
|
-
# option to true.
|
7
|
-
#
|
8
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
-
%w[.. example_helper]))
|
10
|
-
|
11
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
12
|
-
Prawn::Example.generate(filename) do
|
13
|
-
data = [["This row should be repeated on every new page"]]
|
14
|
-
data += [["..."]] * 30
|
15
|
-
|
16
|
-
table(data, :header => true)
|
17
|
-
end
|
data/manual/table/image_cells.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Prawn can insert images into a table. Just pass a hash into
|
4
|
-
# <code>table()</code> with an <code>:image</code> key pointing to the image.
|
5
|
-
#
|
6
|
-
# You can pass the <code>:scale</code>, <code>:fit</code>,
|
7
|
-
# <code>:position</code>, and <code>:vposition</code> arguments in alongside
|
8
|
-
# <code>:image</code>; these will function just as in <code>image()</code>.
|
9
|
-
#
|
10
|
-
# The <code>:image_width</code> and <code>:image_height</code> arguments set
|
11
|
-
# the width/height of the image within the cell, as opposed to the
|
12
|
-
# <code>:width</code> and <code>:height</code> arguments, which set the table
|
13
|
-
# cell's dimensions.
|
14
|
-
#
|
15
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
16
|
-
%w[.. example_helper]))
|
17
|
-
|
18
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
19
|
-
Prawn::Example.generate(filename) do
|
20
|
-
image = "#{Prawn::DATADIR}/images/prawn.png"
|
21
|
-
|
22
|
-
table [
|
23
|
-
["Standard image cell", {:image => image}],
|
24
|
-
[":scale => 0.5", {:image => image, :scale => 0.5}],
|
25
|
-
[":fit => [100, 200]", {:image => image, :fit => [100, 200]}],
|
26
|
-
[":image_height => 50,
|
27
|
-
:image_width => 100", {:image => image, :image_height => 50,
|
28
|
-
:image_width => 100}],
|
29
|
-
[":position => :center", {:image => image, :position => :center}],
|
30
|
-
[":vposition => :center", {:image => image, :vposition => :center,
|
31
|
-
:height => 200}]
|
32
|
-
], :width => bounds.width
|
33
|
-
end
|
data/manual/table/position.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# The <code>table()</code> method accepts a <code>:position</code> argument to
|
4
|
-
# determine horizontal position of the table within its bounding box. It can be
|
5
|
-
# <code>:left</code> (the default), <code>:center</code>, <code>:right</code>,
|
6
|
-
# or a number specifying a distance in PDF points from the left side.
|
7
|
-
#
|
8
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
-
%w[.. example_helper]))
|
10
|
-
|
11
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
12
|
-
Prawn::Example.generate(filename) do
|
13
|
-
data = [["The quick brown fox jumped over the lazy dogs."]] * 2
|
14
|
-
|
15
|
-
text "Left:"
|
16
|
-
table data, :position => :left
|
17
|
-
move_down 10
|
18
|
-
|
19
|
-
text "Center:"
|
20
|
-
table data, :position => :center
|
21
|
-
move_down 10
|
22
|
-
|
23
|
-
text "Right:"
|
24
|
-
table data, :position => :right
|
25
|
-
move_down 10
|
26
|
-
|
27
|
-
text "100pt:"
|
28
|
-
table data, :position => 100
|
29
|
-
end
|
data/manual/table/row_colors.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# One of the most common table styling techniques is to stripe the rows with
|
4
|
-
# alternating colors.
|
5
|
-
#
|
6
|
-
# There is one helper just for that. Just provide the <code>:row_colors</code>
|
7
|
-
# option an array with color values.
|
8
|
-
#
|
9
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
10
|
-
%w[.. example_helper]))
|
11
|
-
|
12
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
13
|
-
Prawn::Example.generate(filename) do
|
14
|
-
data = [["This row should have one color"],
|
15
|
-
["And this row should have another"]]
|
16
|
-
|
17
|
-
data += [["..."]] * 10
|
18
|
-
|
19
|
-
table(data, :row_colors => ["F0F0F0", "FFFFCC"])
|
20
|
-
end
|
data/manual/table/span.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Table cells can span multiple columns, rows, or both. When building a cell,
|
4
|
-
# use the hash argument constructor with a <code>:colspan</code> and/or
|
5
|
-
# <code>:rowspan</code> argument. Row or column spanning must be specified when
|
6
|
-
# building the data array; you can't set the span in the table's initialization
|
7
|
-
# block. This is because cells are laid out in the grid before that block is
|
8
|
-
# called, so that references to row and column numbers make sense.
|
9
|
-
#
|
10
|
-
# Cells are laid out in the order given, skipping any positions spanned by
|
11
|
-
# previously instantiated cells. Therefore, a cell with <code>rowspan: 2</code>
|
12
|
-
# will be missing at least one cell in the row below it. See the code and table
|
13
|
-
# below for an example.
|
14
|
-
#
|
15
|
-
# It is illegal to overlap cells via spanning. A
|
16
|
-
# <code>Prawn::Errors::InvalidTableSpan</code> error will be raised if spans
|
17
|
-
# would cause cells to overlap.
|
18
|
-
#
|
19
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
20
|
-
%w[.. example_helper]))
|
21
|
-
|
22
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
23
|
-
Prawn::Example.generate(filename) do
|
24
|
-
table([
|
25
|
-
["A", {:content => "2x1", :colspan => 2}, "B"],
|
26
|
-
[{:content => "1x2", :rowspan => 2}, "C", "D", "E"],
|
27
|
-
[{:content => "2x2", :colspan => 2, :rowspan => 2}, "F"],
|
28
|
-
["G", "H"]
|
29
|
-
])
|
30
|
-
end
|
data/manual/table/style.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# We've seen how to apply styles to a selection of cells by setting the
|
4
|
-
# individual properties. Another option is to use the <code>style</code> method
|
5
|
-
#
|
6
|
-
# <code>style</code> lets us define multiple properties at once with a hash. It
|
7
|
-
# also accepts a block that will be called for each cell and can be used for
|
8
|
-
# some complex styling.
|
9
|
-
#
|
10
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
11
|
-
%w[.. example_helper]))
|
12
|
-
|
13
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
14
|
-
Prawn::Example.generate(filename) do
|
15
|
-
table([[""] * 8] * 8) do
|
16
|
-
cells.style(:width => 24, :height => 24)
|
17
|
-
|
18
|
-
cells.style do |c|
|
19
|
-
c.background_color = ((c.row + c.column) % 2).zero? ? '000000' : 'ffffff'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/manual/table/table.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Examples for tables.
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Example.generate("table.pdf", :page_size => "FOLIO") do
|
9
|
-
|
10
|
-
package "table" do |p|
|
11
|
-
|
12
|
-
p.section "Basics" do |s|
|
13
|
-
s.example "creation"
|
14
|
-
s.example "content_and_subtables"
|
15
|
-
s.example "flow_and_header"
|
16
|
-
s.example "position"
|
17
|
-
end
|
18
|
-
|
19
|
-
p.section "Styling" do |s|
|
20
|
-
s.example "column_widths"
|
21
|
-
s.example "width"
|
22
|
-
s.example "row_colors"
|
23
|
-
s.example "cell_dimensions"
|
24
|
-
s.example "cell_borders_and_bg"
|
25
|
-
s.example "cell_border_lines"
|
26
|
-
s.example "cell_text"
|
27
|
-
s.example "image_cells"
|
28
|
-
s.example "span"
|
29
|
-
s.example "before_rendering_page"
|
30
|
-
end
|
31
|
-
|
32
|
-
p.section "Initializer Block" do |s|
|
33
|
-
s.example "basic_block"
|
34
|
-
s.example "filtering"
|
35
|
-
s.example "style"
|
36
|
-
end
|
37
|
-
|
38
|
-
p.intro do
|
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
|
-
|
41
|
-
The examples show:")
|
42
|
-
|
43
|
-
list( "How to create tables",
|
44
|
-
"What content can be placed on tables",
|
45
|
-
"Subtables (or tables within tables)",
|
46
|
-
"How to style the whole table",
|
47
|
-
"How to use initializer blocks to style only specific portions of the table"
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
data/manual/table/width.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# The default table width depends on the content provided. It will expand up
|
4
|
-
# to the current bounding box width to fit the content. If you want the table to
|
5
|
-
# have a fixed width no matter the content you may use the <code>:width</code>
|
6
|
-
# option to manually set the width.
|
7
|
-
#
|
8
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
-
%w[.. example_helper]))
|
10
|
-
|
11
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
12
|
-
Prawn::Example.generate(filename) do
|
13
|
-
text "Normal width:"
|
14
|
-
table [%w[A B C]]
|
15
|
-
move_down 20
|
16
|
-
|
17
|
-
text "Fixed width:"
|
18
|
-
table([%w[A B C]], :width => 300)
|
19
|
-
move_down 20
|
20
|
-
|
21
|
-
text "Normal width:"
|
22
|
-
table([["A", "Blah " * 20, "C"]])
|
23
|
-
move_down 20
|
24
|
-
|
25
|
-
text "Fixed width:"
|
26
|
-
table([["A", "Blah " * 20, "C"]], :width => 300)
|
27
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
#<b>NOTE: Templates are currently unmaintained and may be removed by Prawn 1.0!</b>
|
4
|
-
#
|
5
|
-
# You may load another PDF while creating a new one. Just pass the loaded PDF
|
6
|
-
# filename to the <code>:template</code> option when creating/generating the new
|
7
|
-
# PDF.
|
8
|
-
#
|
9
|
-
# The provided PDF will be loaded and its first page will be set as the
|
10
|
-
# current page. If you'd like to resume the document you may take advantage of
|
11
|
-
# two helpers: <code>page_count</code> and <code>go_to_page</code>.
|
12
|
-
#
|
13
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
14
|
-
%w[.. example_helper]))
|
15
|
-
|
16
|
-
filename = "#{Prawn::DATADIR}/pdfs/multipage_template.pdf"
|
17
|
-
|
18
|
-
Prawn::Example.generate("full_template.pdf", :template => filename) do
|
19
|
-
go_to_page(page_count)
|
20
|
-
|
21
|
-
start_new_page
|
22
|
-
|
23
|
-
text "Previous pages and content imported.", :align => :center
|
24
|
-
text "This page and content is brand new.", :align => :center
|
25
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# <b>NOTE: Templates are currently unmaintained and may be removed by Prawn 1.0!</b>
|
3
|
-
#
|
4
|
-
# If you only need to load some pages from another PDF, you can accomplish it
|
5
|
-
# with the <code>start_new_page</code> method. You may pass it a
|
6
|
-
# <code>:template</code> option with the path for an existing pdf and a
|
7
|
-
# <code>:template_page</code> option to specify which page to load.
|
8
|
-
# You can also load a <code>:template</code> using a URI:
|
9
|
-
#
|
10
|
-
# <code>require 'open-uri'</code>
|
11
|
-
#
|
12
|
-
# <code>start_new_page(:template => open('url_for_your.pdf'))</code>
|
13
|
-
#
|
14
|
-
# The following example loads some pages from an existing PDF. If we don't
|
15
|
-
# specify the <code>:template_page</code> option, the first page of the template
|
16
|
-
# PDF will be loaded. That's what happens on the first load below. Then we load
|
17
|
-
# a page by specifying the <code>:template_page</code> option and then we do it
|
18
|
-
# again this time adding some content to the loaded page.
|
19
|
-
#
|
20
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
21
|
-
%w[.. example_helper]))
|
22
|
-
|
23
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
24
|
-
Prawn::Example.generate(filename) do
|
25
|
-
text "Please scan the next 3 pages to see the page templates in action."
|
26
|
-
move_down 10
|
27
|
-
text "You also might want to look at the pdf used as a template: "
|
28
|
-
url = "https://github.com/prawnpdf/prawn/raw/master/data/pdfs/form.pdf"
|
29
|
-
move_down 10
|
30
|
-
|
31
|
-
formatted_text [{:text => url, :link => url}]
|
32
|
-
|
33
|
-
filename = "#{Prawn::DATADIR}/pdfs/form.pdf"
|
34
|
-
start_new_page(:template => filename)
|
35
|
-
|
36
|
-
start_new_page(:template => filename, :template_page => 2)
|
37
|
-
|
38
|
-
start_new_page(:template => filename, :template_page => 2)
|
39
|
-
|
40
|
-
fill_color "FF8888"
|
41
|
-
|
42
|
-
text_box "John Doe", :at => [75, cursor-75]
|
43
|
-
text_box "john@doe.com", :at => [75, cursor-105]
|
44
|
-
text_box "John Doe inc", :at => [75, cursor-135]
|
45
|
-
text_box "You didn't think I'd tell, did you?", :at => [75, cursor-165]
|
46
|
-
|
47
|
-
fill_color "000000"
|
48
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Examples for loading existing pdfs.
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Example.generate("templates.pdf", :page_size => "FOLIO") do
|
9
|
-
|
10
|
-
package "templates" do |p|
|
11
|
-
|
12
|
-
p.example "full_template", :eval_source => false, :full_source => true
|
13
|
-
p.example "page_template"
|
14
|
-
|
15
|
-
p.intro do
|
16
|
-
prose("<b>NOTE: Templates are currently unmaintained and may be removed by Prawn 1.0!</b>")
|
17
|
-
prose("Templates let you embed other PDF documents inside the current one.
|
18
|
-
|
19
|
-
The examples show:")
|
20
|
-
|
21
|
-
list( "How to load the whole content from another PDF",
|
22
|
-
"How to load single pages from another PDF"
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
data/manual/text/group.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Sometimes free flowing text might look ugly, specially when a paragraph is
|
4
|
-
# split between two pages. Using a positioned text box just to overcome this
|
5
|
-
# nuisance is not the right choice.
|
6
|
-
#
|
7
|
-
# You probably want to use the <code>group</code> method instead. It will try
|
8
|
-
# to render the block within the current page. If the content would fall to a
|
9
|
-
# new page it just renders everything on the following page. If the block cannot
|
10
|
-
# be executed on a single blank page a <code>CannotGroup</code> exception will
|
11
|
-
# be raised.
|
12
|
-
#
|
13
|
-
# So if you can split your text blocks in paragraphs you can have every
|
14
|
-
# paragraph contained on a single page.
|
15
|
-
#
|
16
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
17
|
-
%w[.. example_helper]))
|
18
|
-
|
19
|
-
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
20
|
-
Prawn::Example.generate(filename) do
|
21
|
-
move_cursor_to 80
|
22
|
-
text "Let's move to the end of the page so that you can see group in action."
|
23
|
-
|
24
|
-
group do
|
25
|
-
text "This block of text was too big to be rendered on the bottom of the " +
|
26
|
-
" previous page. So it was rendered entirely on this new page. " +
|
27
|
-
" _ " * 200
|
28
|
-
end
|
29
|
-
end
|
data/spec/acceptance/png.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative "../../lib/prawn"
|
2
|
-
|
3
|
-
images = [
|
4
|
-
["Type 0", "#{Prawn::BASEDIR}/data/images/web-links.png"],
|
5
|
-
["Type 2", "#{Prawn::BASEDIR}/data/images/ruport.png"],
|
6
|
-
["Type 3", "#{Prawn::BASEDIR}/data/images/indexed_color.png"],
|
7
|
-
["Type 4", "#{Prawn::BASEDIR}/data/images/page_white_text.png"],
|
8
|
-
["Type 6", "#{Prawn::BASEDIR}/data/images/dice.png"],
|
9
|
-
]
|
10
|
-
|
11
|
-
Prawn::Document.generate("png_types.pdf", :page_size => "A5") do
|
12
|
-
images.each do |header, file|
|
13
|
-
start_new_page unless header.include?("0")
|
14
|
-
|
15
|
-
fill_color "FF0000"
|
16
|
-
|
17
|
-
fill_rectangle bounds.top_left, bounds.width, bounds.height
|
18
|
-
text header
|
19
|
-
|
20
|
-
image file, :at => [50,450]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
data/spec/annotations_spec.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
-
|
5
|
-
|
6
|
-
describe "When creating annotations" do
|
7
|
-
|
8
|
-
before(:each) { create_pdf }
|
9
|
-
|
10
|
-
it "should append annotation to current page" do
|
11
|
-
@pdf.start_new_page
|
12
|
-
@pdf.annotate(:Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
|
13
|
-
PDF::Reader.open(StringIO.new(@pdf.render)) do |pdf|
|
14
|
-
pdf.page(1).attributes[:Annots].should be_nil
|
15
|
-
pdf.page(2).attributes[:Annots].size.should == 1
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should force :Type to be :Annot" do
|
20
|
-
opts = @pdf.annotate(:Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
|
21
|
-
opts[:Type].should == :Annot
|
22
|
-
opts = @pdf.annotate(:Type => :Bogus, :Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
|
23
|
-
opts[:Type].should == :Annot
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "When creating text annotations" do
|
29
|
-
|
30
|
-
before(:each) do
|
31
|
-
@rect = [0,0,10,10]
|
32
|
-
@content = "Hello, world!"
|
33
|
-
create_pdf
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should build appropriate annotation" do
|
37
|
-
opts = @pdf.text_annotation(@rect, @content)
|
38
|
-
opts[:Type].should == :Annot
|
39
|
-
opts[:Subtype].should == :Text
|
40
|
-
opts[:Rect].should == @rect
|
41
|
-
opts[:Contents].should == @content
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should merge extra options" do
|
45
|
-
opts = @pdf.text_annotation(@rect, @content, :Open => true, :Subtype => :Bogus)
|
46
|
-
opts[:Subtype].should == :Text
|
47
|
-
opts[:Open].should == true
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "When creating link annotations" do
|
53
|
-
|
54
|
-
before(:each) do
|
55
|
-
@rect = [0,0,10,10]
|
56
|
-
@dest = "home"
|
57
|
-
create_pdf
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should build appropriate annotation" do
|
61
|
-
opts = @pdf.link_annotation(@rect, :Dest => @dest)
|
62
|
-
opts[:Type].should == :Annot
|
63
|
-
opts[:Subtype].should == :Link
|
64
|
-
opts[:Rect].should == @rect
|
65
|
-
opts[:Dest].should == @dest
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should merge extra options" do
|
69
|
-
opts = @pdf.link_annotation(@rect, :Dest => @dest, :Subtype => :Bogus)
|
70
|
-
opts[:Subtype].should == :Link
|
71
|
-
opts[:Dest].should == @dest
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|