prawn 0.11.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +10 -0
- data/COPYING +2 -2
- data/GPLv2 +340 -0
- data/GPLv3 +674 -0
- data/Gemfile +11 -0
- data/LICENSE +1 -1
- data/Rakefile +29 -38
- data/data/images/16bit.alpha +0 -0
- data/data/images/16bit.color +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.color +0 -0
- data/data/images/indexed_color.dat +0 -0
- data/data/images/indexed_color.png +0 -0
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.color +0 -0
- data/data/pdfs/nested_pages.pdf +13 -13
- data/lib/prawn/document/bounding_box.rb +87 -12
- data/lib/prawn/document/column_box.rb +57 -28
- data/lib/prawn/document/graphics_state.rb +11 -74
- data/lib/prawn/document/internals.rb +25 -23
- data/lib/prawn/document/snapshot.rb +11 -8
- data/lib/prawn/document/span.rb +12 -10
- data/lib/prawn/document.rb +250 -194
- data/lib/prawn/encoding.rb +9 -10
- data/lib/prawn/errors.rb +18 -29
- data/lib/prawn/font/afm.rb +52 -41
- data/lib/prawn/font/dfont.rb +4 -3
- data/lib/prawn/font/ttf.rb +44 -48
- data/lib/prawn/font.rb +138 -88
- data/lib/prawn/font_metric_cache.rb +47 -0
- data/lib/prawn/graphics/cap_style.rb +4 -3
- data/lib/prawn/graphics/color.rb +13 -5
- data/lib/prawn/graphics/dash.rb +53 -31
- data/lib/prawn/graphics/join_style.rb +9 -7
- data/lib/prawn/graphics/patterns.rb +138 -0
- data/lib/prawn/graphics/transformation.rb +10 -9
- data/lib/prawn/graphics/transparency.rb +3 -1
- data/lib/prawn/graphics.rb +316 -61
- data/lib/prawn/image_handler.rb +36 -0
- data/lib/prawn/images/image.rb +49 -0
- data/lib/prawn/images/jpg.rb +21 -15
- data/lib/prawn/images/png.rb +62 -119
- data/lib/prawn/images.rb +89 -108
- data/lib/prawn/layout/grid.rb +66 -54
- data/lib/prawn/layout.rb +10 -15
- data/lib/prawn/measurement_extensions.rb +10 -6
- data/lib/prawn/measurements.rb +27 -21
- data/lib/prawn/outline.rb +6 -308
- data/lib/prawn/repeater.rb +11 -9
- data/lib/prawn/security/arcfour.rb +1 -0
- data/lib/prawn/security.rb +55 -33
- data/lib/prawn/soft_mask.rb +96 -0
- data/lib/prawn/stamp.rb +5 -3
- data/lib/prawn/table/cell/image.rb +69 -0
- data/lib/prawn/table/cell/in_table.rb +4 -2
- data/lib/prawn/table/cell/span_dummy.rb +93 -0
- data/lib/prawn/table/cell/subtable.rb +2 -2
- data/lib/prawn/table/cell/text.rb +44 -26
- data/lib/prawn/table/cell.rb +302 -50
- data/lib/prawn/table/cells.rb +147 -49
- data/lib/prawn/table/column_width_calculator.rb +61 -0
- data/lib/prawn/table.rb +297 -118
- data/lib/prawn/text/box.rb +21 -5
- data/lib/prawn/text/formatted/arranger.rb +290 -0
- data/lib/prawn/text/formatted/box.rb +103 -59
- data/lib/prawn/text/formatted/fragment.rb +34 -23
- data/lib/prawn/text/formatted/line_wrap.rb +266 -0
- data/lib/prawn/text/formatted/parser.rb +15 -5
- data/lib/prawn/text/formatted/wrap.rb +150 -0
- data/lib/prawn/text/formatted.rb +5 -4
- data/lib/prawn/text.rb +38 -24
- data/lib/prawn/utilities.rb +46 -0
- data/lib/prawn.rb +85 -20
- data/manual/basic_concepts/adding_pages.rb +27 -0
- data/manual/basic_concepts/basic_concepts.rb +34 -0
- data/manual/basic_concepts/creation.rb +39 -0
- data/manual/basic_concepts/cursor.rb +33 -0
- data/manual/basic_concepts/measurement.rb +25 -0
- data/manual/basic_concepts/origin.rb +38 -0
- data/manual/basic_concepts/other_cursor_helpers.rb +40 -0
- data/manual/bounding_box/bounding_box.rb +39 -0
- data/manual/bounding_box/bounds.rb +49 -0
- data/manual/bounding_box/canvas.rb +24 -0
- data/manual/bounding_box/creation.rb +23 -0
- data/manual/bounding_box/indentation.rb +46 -0
- data/manual/bounding_box/nesting.rb +45 -0
- data/manual/bounding_box/russian_boxes.rb +40 -0
- data/manual/bounding_box/stretchy.rb +31 -0
- data/manual/document_and_page_options/background.rb +27 -0
- data/manual/document_and_page_options/document_and_page_options.rb +32 -0
- data/manual/document_and_page_options/metadata.rb +23 -0
- data/manual/document_and_page_options/page_margins.rb +38 -0
- data/manual/document_and_page_options/page_size.rb +34 -0
- data/manual/document_and_page_options/print_scaling.rb +20 -0
- data/manual/example_file.rb +111 -0
- data/manual/example_helper.rb +411 -0
- data/manual/example_package.rb +53 -0
- data/manual/example_section.rb +46 -0
- data/manual/graphics/circle_and_ellipse.rb +22 -0
- data/manual/graphics/color.rb +24 -0
- data/manual/graphics/common_lines.rb +30 -0
- data/manual/graphics/fill_and_stroke.rb +42 -0
- data/manual/graphics/fill_rules.rb +37 -0
- data/manual/graphics/gradients.rb +37 -0
- data/manual/graphics/graphics.rb +58 -0
- data/manual/graphics/helper.rb +24 -0
- data/manual/graphics/line_width.rb +35 -0
- data/manual/graphics/lines_and_curves.rb +41 -0
- data/manual/graphics/polygon.rb +29 -0
- data/manual/graphics/rectangle.rb +21 -0
- data/manual/graphics/rotate.rb +28 -0
- data/manual/graphics/scale.rb +41 -0
- data/manual/graphics/soft_masks.rb +46 -0
- data/manual/graphics/stroke_cap.rb +31 -0
- data/manual/graphics/stroke_dash.rb +48 -0
- data/manual/graphics/stroke_join.rb +30 -0
- data/manual/graphics/translate.rb +29 -0
- data/manual/graphics/transparency.rb +35 -0
- data/manual/images/absolute_position.rb +23 -0
- data/manual/images/fit.rb +21 -0
- data/manual/images/horizontal.rb +25 -0
- data/manual/images/images.rb +40 -0
- data/manual/images/plain_image.rb +18 -0
- data/manual/images/scale.rb +22 -0
- data/manual/images/vertical.rb +28 -0
- data/manual/images/width_and_height.rb +25 -0
- data/manual/layout/boxes.rb +27 -0
- data/manual/layout/content.rb +25 -0
- data/manual/layout/layout.rb +28 -0
- data/manual/layout/simple_grid.rb +23 -0
- data/manual/manual/cover.rb +36 -0
- data/manual/manual/foreword.rb +85 -0
- data/manual/manual/how_to_read_this_manual.rb +41 -0
- data/manual/manual/manual.rb +34 -0
- data/manual/outline/add_subsection_to.rb +61 -0
- data/manual/outline/insert_section_after.rb +47 -0
- data/manual/outline/outline.rb +32 -0
- data/manual/outline/sections_and_pages.rb +67 -0
- data/manual/repeatable_content/page_numbering.rb +54 -0
- data/manual/repeatable_content/repeatable_content.rb +31 -0
- data/manual/repeatable_content/repeater.rb +55 -0
- data/manual/repeatable_content/stamp.rb +41 -0
- data/manual/security/encryption.rb +31 -0
- data/manual/security/permissions.rb +38 -0
- data/manual/security/security.rb +28 -0
- data/manual/syntax_highlight.rb +52 -0
- data/manual/table/basic_block.rb +53 -0
- data/manual/table/before_rendering_page.rb +26 -0
- data/manual/table/cell_border_lines.rb +24 -0
- data/manual/table/cell_borders_and_bg.rb +31 -0
- data/manual/table/cell_dimensions.rb +30 -0
- data/manual/table/cell_text.rb +38 -0
- data/manual/table/column_widths.rb +30 -0
- data/manual/table/content_and_subtables.rb +39 -0
- data/manual/table/creation.rb +27 -0
- data/manual/table/filtering.rb +36 -0
- data/manual/table/flow_and_header.rb +17 -0
- data/manual/table/image_cells.rb +33 -0
- data/manual/table/position.rb +29 -0
- data/manual/table/row_colors.rb +20 -0
- data/manual/table/span.rb +30 -0
- data/manual/table/style.rb +22 -0
- data/manual/table/table.rb +52 -0
- data/manual/table/width.rb +27 -0
- data/manual/text/alignment.rb +44 -0
- data/manual/text/color.rb +24 -0
- data/manual/text/column_box.rb +32 -0
- data/manual/text/fallback_fonts.rb +37 -0
- data/manual/text/font.rb +41 -0
- data/manual/text/font_size.rb +45 -0
- data/manual/text/font_style.rb +23 -0
- data/manual/text/formatted_callbacks.rb +60 -0
- data/manual/text/formatted_text.rb +54 -0
- data/manual/text/free_flowing_text.rb +51 -0
- data/manual/text/group.rb +31 -0
- data/manual/text/inline.rb +43 -0
- data/manual/text/kerning_and_character_spacing.rb +39 -0
- data/manual/text/leading.rb +25 -0
- data/manual/text/line_wrapping.rb +41 -0
- data/manual/text/paragraph_indentation.rb +26 -0
- data/manual/text/positioned_text.rb +38 -0
- data/manual/text/registering_families.rb +48 -0
- data/manual/text/rendering_and_color.rb +37 -0
- data/manual/text/right_to_left_text.rb +43 -0
- data/manual/text/rotation.rb +43 -0
- data/manual/text/single_usage.rb +37 -0
- data/manual/text/text.rb +75 -0
- data/manual/text/text_box_excess.rb +32 -0
- data/manual/text/text_box_extensions.rb +45 -0
- data/manual/text/text_box_overflow.rb +44 -0
- data/manual/text/utf8.rb +28 -0
- data/{examples/m17n → manual/text}/win_ansi_charset.rb +14 -10
- data/prawn.gemspec +27 -17
- data/spec/acceptance/png.rb +23 -0
- data/spec/annotations_spec.rb +16 -32
- data/spec/bounding_box_spec.rb +284 -2
- data/spec/cell_spec.rb +169 -38
- data/spec/column_box_spec.rb +65 -0
- data/spec/data/curves.pdf +66 -0
- data/spec/destinations_spec.rb +5 -5
- data/spec/document_spec.rb +212 -113
- data/spec/extensions/encoding_helpers.rb +9 -0
- data/spec/extensions/mocha.rb +2 -3
- data/spec/font_metric_cache_spec.rb +52 -0
- data/spec/font_spec.rb +205 -95
- data/spec/formatted_text_arranger_spec.rb +43 -43
- data/spec/formatted_text_box_spec.rb +63 -24
- data/spec/formatted_text_fragment_spec.rb +8 -8
- data/spec/graphics_spec.rb +175 -68
- data/spec/grid_spec.rb +26 -15
- data/spec/image_handler_spec.rb +54 -0
- data/spec/images_spec.rb +58 -30
- data/spec/inline_formatted_text_parser_spec.rb +73 -19
- data/spec/jpg_spec.rb +4 -4
- data/spec/line_wrap_spec.rb +28 -28
- data/spec/measurement_units_spec.rb +6 -6
- data/spec/object_store_spec.rb +17 -106
- data/spec/outline_spec.rb +103 -63
- data/spec/png_spec.rb +25 -25
- data/spec/reference_spec.rb +8 -65
- data/spec/repeater_spec.rb +25 -11
- data/spec/security_spec.rb +44 -12
- data/spec/snapshot_spec.rb +38 -6
- data/spec/soft_mask_spec.rb +117 -0
- data/spec/span_spec.rb +10 -15
- data/spec/spec_helper.rb +32 -8
- data/spec/stamp_spec.rb +29 -30
- data/spec/stroke_styles_spec.rb +36 -18
- data/spec/table/span_dummy_spec.rb +17 -0
- data/spec/table_spec.rb +850 -104
- data/spec/text_at_spec.rb +19 -33
- data/spec/text_box_spec.rb +117 -64
- data/spec/text_rendering_mode_spec.rb +5 -5
- data/spec/text_spacing_spec.rb +20 -2
- data/spec/text_spec.rb +111 -59
- data/spec/transparency_spec.rb +5 -5
- metadata +477 -328
- data/HACKING +0 -50
- data/README +0 -141
- data/data/fonts/Action Man.dfont +0 -0
- data/data/fonts/Activa.ttf +0 -0
- data/data/fonts/Chalkboard.ttf +0 -0
- data/data/fonts/DejaVuSans.ttf +0 -0
- data/data/fonts/Dustismo_Roman.ttf +0 -0
- data/data/fonts/comicsans.ttf +0 -0
- data/data/fonts/gkai00mp.ttf +0 -0
- data/data/images/16bit.dat +0 -0
- data/data/images/dice.dat +0 -0
- data/data/images/page_white_text.dat +0 -0
- data/data/images/rails.dat +0 -0
- data/data/images/rails.png +0 -0
- data/examples/bounding_box/bounding_boxes.rb +0 -44
- data/examples/bounding_box/indentation.rb +0 -35
- data/examples/bounding_box/russian_boxes.rb +0 -37
- data/examples/bounding_box/stretched_nesting.rb +0 -68
- data/examples/example_helper.rb +0 -8
- data/examples/general/background.rb +0 -24
- data/examples/general/canvas.rb +0 -16
- data/examples/general/context_sensitive_headers.rb +0 -38
- 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/cmyk.rb +0 -13
- data/examples/graphics/curves.rb +0 -12
- data/examples/graphics/gradient.rb +0 -23
- 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/png_types.rb +0 -23
- data/examples/graphics/polygons.rb +0 -17
- data/examples/graphics/remote_images.rb +0 -13
- 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/full_win_ansi_character_list.rb +0 -20
- data/examples/m17n/sjis.rb +0 -29
- data/examples/m17n/utf8.rb +0 -14
- data/examples/security/hello_foo.rb +0 -9
- data/examples/table/bill.rb +0 -54
- data/examples/table/borders.rb +0 -25
- data/examples/table/cell.rb +0 -13
- data/examples/table/checkerboard.rb +0 -23
- data/examples/table/header.rb +0 -15
- 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_calculations.rb +0 -92
- data/examples/text/font_size.rb +0 -34
- data/examples/text/hyphenation.rb +0 -45
- data/examples/text/indent_paragraphs.rb +0 -24
- 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
- data/lib/prawn/compatibility.rb +0 -51
- data/lib/prawn/core/annotations.rb +0 -61
- data/lib/prawn/core/byte_string.rb +0 -9
- data/lib/prawn/core/destinations.rb +0 -90
- data/lib/prawn/core/document_state.rb +0 -78
- data/lib/prawn/core/literal_string.rb +0 -16
- data/lib/prawn/core/name_tree.rb +0 -165
- data/lib/prawn/core/object_store.rb +0 -264
- data/lib/prawn/core/page.rb +0 -213
- data/lib/prawn/core/pdf_object.rb +0 -108
- data/lib/prawn/core/reference.rb +0 -112
- data/lib/prawn/core/text/formatted/arranger.rb +0 -293
- data/lib/prawn/core/text/formatted/line_wrap.rb +0 -272
- data/lib/prawn/core/text/formatted/wrap.rb +0 -149
- data/lib/prawn/core/text.rb +0 -268
- data/lib/prawn/core.rb +0 -85
- data/lib/prawn/document/page_geometry.rb +0 -136
- data/lib/prawn/graphics/gradient.rb +0 -84
- data/spec/name_tree_spec.rb +0 -112
- data/spec/pdf_object_spec.rb +0 -170
- data/spec/template_spec.rb +0 -291
data/examples/text/dfont.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
-
%w[.. example_helper]))
|
5
|
-
|
6
|
-
DFONT_FILE = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
|
7
|
-
puts "There are #{Prawn::Font::DFont.font_count(DFONT_FILE)} fonts in #{DFONT_FILE}:"
|
8
|
-
Prawn::Font::DFont.named_fonts(DFONT_FILE).each do |name|
|
9
|
-
puts "* #{name}"
|
10
|
-
end
|
11
|
-
|
12
|
-
puts
|
13
|
-
puts "generating sample document in 'dfont.pdf'..."
|
14
|
-
|
15
|
-
Prawn::Document.generate "dfont.pdf" do
|
16
|
-
fill_color "0000ff"
|
17
|
-
|
18
|
-
font DFONT_FILE, :font => "ActionMan-Bold", :size => 24
|
19
|
-
text "Introducing Action Man!"
|
20
|
-
|
21
|
-
move_text_position 24
|
22
|
-
|
23
|
-
font_families["Action Man"] = {
|
24
|
-
:normal => { :file => DFONT_FILE, :font => "ActionMan" },
|
25
|
-
:bold => { :file => DFONT_FILE, :font => "ActionMan-Bold" },
|
26
|
-
:italic => { :file => DFONT_FILE, :font => "ActionMan-Italic" },
|
27
|
-
:bold_italic => { :file => DFONT_FILE, :font => "ActionMan-BoldItalic" }
|
28
|
-
}
|
29
|
-
|
30
|
-
font "Action Man", :size => 16
|
31
|
-
text "Action Man is feeling normal here."
|
32
|
-
|
33
|
-
move_text_position 16
|
34
|
-
|
35
|
-
font "Action Man", :style => :bold, :size => 16
|
36
|
-
text "Action Man is feeling bold here!"
|
37
|
-
|
38
|
-
move_text_position 16
|
39
|
-
|
40
|
-
font "Action Man", :style => :italic, :size => 16
|
41
|
-
text "Here, we see Action Man feeling italicized. Slick!"
|
42
|
-
|
43
|
-
move_text_position 16
|
44
|
-
|
45
|
-
font "Action Man", :style => :bold_italic, :size => 16
|
46
|
-
text "Lastly, we observe Mr. Action Man being bold AND italicized. Excellent!"
|
47
|
-
end
|
48
|
-
|
49
|
-
puts "done"
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This example demonstrates using the :style option for Document#text.
|
4
|
-
# If you are working with TTF fonts, you'll want to check out the
|
5
|
-
# documentation for Document#font_families and register your fonts with it.
|
6
|
-
#
|
7
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
-
%w[.. example_helper]))
|
9
|
-
|
10
|
-
Prawn::Document.generate("family_style.pdf") do
|
11
|
-
["Courier","Helvetica","Times-Roman"].each do |f|
|
12
|
-
[:bold,:bold_italic,:italic,:normal].each do |s|
|
13
|
-
font f, :style => s
|
14
|
-
text "I'm writing in #{f} (#{s})"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
font "Helvetica"
|
19
|
-
|
20
|
-
text "Normal"
|
21
|
-
text "Bold", :style => :bold
|
22
|
-
text "Bold Italic", :style => :bold_italic
|
23
|
-
text "Italic", :style => :italic
|
24
|
-
text "Normal"
|
25
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This example is a demonstration of how Prawn does its text positioning,
|
4
|
-
# meant to assist those that need to do advanced positioning calculations.
|
5
|
-
# Run the example for a clearer picture of how things work
|
6
|
-
#
|
7
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
-
%w[.. example_helper]))
|
9
|
-
|
10
|
-
Prawn::Document.generate('font_calculations.pdf') do
|
11
|
-
|
12
|
-
def demonstration
|
13
|
-
font_size 12
|
14
|
-
move_down 10
|
15
|
-
|
16
|
-
stroke_horizontal_rule
|
17
|
-
|
18
|
-
text "When using flowing text, Prawn will position text\n" +
|
19
|
-
"starting font.ascender below the baseline, and leave\n" +
|
20
|
-
"the y-cursor at the baseline of the next line of text"
|
21
|
-
|
22
|
-
stroke_horizontal_rule
|
23
|
-
|
24
|
-
move_down 20
|
25
|
-
|
26
|
-
bl = y - bounds.absolute_bottom
|
27
|
-
|
28
|
-
stroke_horizontal_rule
|
29
|
-
draw_text "When using text positioned with :at, the baseline is used", :at => [0, bl]
|
30
|
-
|
31
|
-
draw_text "(and the Y-cursor is not moved)", :at => [350, bl]
|
32
|
-
|
33
|
-
colors = { :ascender => "ff0000",
|
34
|
-
:descender => "00ff00",
|
35
|
-
:line_gap => "0000ff",
|
36
|
-
:font_height => "005500" }
|
37
|
-
|
38
|
-
|
39
|
-
pad(20) do
|
40
|
-
text "Calculations Demo", :size => 16
|
41
|
-
end
|
42
|
-
|
43
|
-
fill_color colors[:ascender]
|
44
|
-
text "ASCENDER"
|
45
|
-
|
46
|
-
fill_color colors[:descender]
|
47
|
-
text "DESCENDER"
|
48
|
-
|
49
|
-
fill_color colors[:line_gap]
|
50
|
-
text "LINEGAP"
|
51
|
-
|
52
|
-
fill_color colors[:font_height]
|
53
|
-
text "FONT_HEIGHT"
|
54
|
-
|
55
|
-
fill_color "000000"
|
56
|
-
font_size 16
|
57
|
-
|
58
|
-
move_down 40
|
59
|
-
|
60
|
-
bl = y - bounds.absolute_bottom
|
61
|
-
draw_text "The quick brown fox jumps over the lazy dog.", :at => [0, bl]
|
62
|
-
|
63
|
-
stroke_color colors[:ascender]
|
64
|
-
stroke_line [0, bl], [0, bl + font.ascender]
|
65
|
-
stroke_line [0, bl + font.ascender], [bounds.width, bl + font.ascender]
|
66
|
-
|
67
|
-
stroke_color colors[:descender]
|
68
|
-
stroke_line [0,bl], [0, bl - font.descender]
|
69
|
-
stroke_line [0, bl - font.descender], [bounds.width, bl - font.descender]
|
70
|
-
|
71
|
-
stroke_color colors[:line_gap]
|
72
|
-
stroke_line [0, bl - font.descender], [0,bl - font.descender - font.line_gap]
|
73
|
-
stroke_line [0, bl - font.descender - font.line_gap],
|
74
|
-
[bounds.width,bl - font.descender - font.line_gap]
|
75
|
-
|
76
|
-
stroke_color colors[:font_height]
|
77
|
-
stroke_line [bounds.width, bl + font.ascender],
|
78
|
-
[bounds.width, bl - font.descender - font.line_gap]
|
79
|
-
|
80
|
-
stroke_color "000000"
|
81
|
-
fill_color "000000"
|
82
|
-
end
|
83
|
-
|
84
|
-
text "Using AFM", :size => 20
|
85
|
-
demonstration
|
86
|
-
|
87
|
-
move_down 75
|
88
|
-
font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
89
|
-
text "Using TTF", :size => 20
|
90
|
-
demonstration
|
91
|
-
|
92
|
-
end
|
data/examples/text/font_size.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This example shows the many ways of setting font sizes in Prawn
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Document.generate "font_size.pdf", :page_size => "A4" do
|
9
|
-
|
10
|
-
# Explicit global changes
|
11
|
-
font 'Helvetica'
|
12
|
-
self.font_size = 16
|
13
|
-
|
14
|
-
text 'Font at 16 point'
|
15
|
-
|
16
|
-
# Transactional changes rolled back after block exit
|
17
|
-
font_size 9 do
|
18
|
-
text 'Font at 9 point'
|
19
|
-
# single line changes, not persisted.
|
20
|
-
text 'Font at manual override 20 point', :size => 20
|
21
|
-
text 'Font at 9 point'
|
22
|
-
end
|
23
|
-
|
24
|
-
# Transactional changes rolled back after block exit on full fonts.
|
25
|
-
font("Times-Roman", :style => :italic, :size => 12) do
|
26
|
-
text "Font in times at 12"
|
27
|
-
font_size(16) { text "Font in Times at 16" }
|
28
|
-
end
|
29
|
-
|
30
|
-
text 'Font at 16 point'
|
31
|
-
|
32
|
-
font "Courier", :size => 40
|
33
|
-
text "40 pt!"
|
34
|
-
end
|
@@ -1,45 +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("hyphenation.pdf") do
|
8
|
-
def get_string(i)
|
9
|
-
case i
|
10
|
-
when 0
|
11
|
-
text = "thisissofthyphenatedtext" * 30
|
12
|
-
when 1
|
13
|
-
text = "this-is-hard-hyphenated-text-" * 30
|
14
|
-
when 2
|
15
|
-
text = "this-is-soft-hard-hyphenated-text-" * 30
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
options = {
|
20
|
-
:width => bounds.width * 0.3,
|
21
|
-
:height => bounds.width * 0.3,
|
22
|
-
:at => [0, 0],
|
23
|
-
:align => :left,
|
24
|
-
:document => self
|
25
|
-
}
|
26
|
-
|
27
|
-
stroke_color("555555")
|
28
|
-
3.times do |i|
|
29
|
-
options[:at][0] = (bounds.width - options[:width]) * 0.5 * i
|
30
|
-
options[:at][1] = bounds.height * 0.5 + options[:height] + 50
|
31
|
-
box = Prawn::Text::Box.new(get_string(i), options)
|
32
|
-
box.render
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
|
37
|
-
|
38
|
-
stroke_color("555555")
|
39
|
-
3.times do |i|
|
40
|
-
options[:at][0] = (bounds.width - options[:width]) * 0.5 * i
|
41
|
-
options[:at][1] = bounds.height * 0.5 - 50
|
42
|
-
box = Prawn::Text::Box.new(get_string(i), options)
|
43
|
-
box.render
|
44
|
-
end
|
45
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Example of two ways of indenting paragraphs
|
4
|
-
#
|
5
|
-
#
|
6
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
-
%w[.. example_helper]))
|
8
|
-
|
9
|
-
Prawn::Document.generate "indent_paragraphs.pdf" do |pdf|
|
10
|
-
hello = "hello " * 50
|
11
|
-
world = "world " * 50
|
12
|
-
string = hello + "©\n" + world + "©"
|
13
|
-
pdf.text(string, :indent_paragraphs => 60, :align => :justify)
|
14
|
-
|
15
|
-
pdf.move_cursor_to(pdf.font.height)
|
16
|
-
pdf.text(string, :indent_paragraphs => 60, :align => :justify)
|
17
|
-
|
18
|
-
pdf.move_cursor_to(pdf.font.height * 3)
|
19
|
-
pdf.text(string, :indent_paragraphs => 60, :align => :justify)
|
20
|
-
|
21
|
-
# can also indent using a non-breaking space
|
22
|
-
nbsp = Prawn::Text::NBSP
|
23
|
-
pdf.text("\n\n\n\n#{nbsp * 10}" + hello + "\n#{nbsp * 10}" + world, :align => :justify)
|
24
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This example shows how to use inline formatting
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Document.generate("inline_format.pdf") do |pdf|
|
9
|
-
|
10
|
-
pdf.text("hello <strikethrough><b>world\nhow <i>are</i></b> you?</strikethrough> world, <u>how are you</u> now?",
|
11
|
-
:inline_format => true)
|
12
|
-
pdf.text("<font size='14'>left: </font>" + "hello <b>world <font name='Times-Roman' size='28'>how</font> <i>are</i></b> you? <font size='14'><b>Goodbye.</b></font> " * 8,
|
13
|
-
:inline_format => true)
|
14
|
-
pdf.text("right: " + "hello <b>world how <i>are</i></b> you? " * 2,
|
15
|
-
:inline_format => true,
|
16
|
-
:align => :right)
|
17
|
-
pdf.text("center: " + "hello <b>world <font size='48'>ho<sub>w</sub> <i>are</i></font></b> you? " * 2,
|
18
|
-
:inline_format => true,
|
19
|
-
:align => :center)
|
20
|
-
pdf.text("\njustify: " + "hello <b>world <i>goodbye</i></b> " * 12 + "the end ",
|
21
|
-
:inline_format => true,
|
22
|
-
:align => :justify)
|
23
|
-
pdf.text("\njustify: " + "hello world goodbye " * 12 + "the end ",
|
24
|
-
:inline_format => true,
|
25
|
-
:align => :justify)
|
26
|
-
pdf.text("\njustify: " + "hello world goodbye " * 12 + "the end ",
|
27
|
-
:align => :justify)
|
28
|
-
|
29
|
-
|
30
|
-
pdf.text("<color rgb='00ff00'>link: <font size='24' character_spacing='7.5'>please make</font> <color rgb='#0000ff'><u><link href='http://wiki.github.com/sandal/prawn/'>this</link></u></color> clickable.</color> Here we have A<color rgb='#0000ff'><sup><link href='http://wiki.github.com/sandal/prawn/'>superscript</link></sup></color> link and A<color rgb='#0000ff'><sub><link href='http://wiki.github.com/sandal/prawn/'> subscript</link></sub></color> link.",
|
31
|
-
:inline_format => true)
|
32
|
-
|
33
|
-
pdf.text("<color c='100' m='0' y='0' k='0'><font size='24'>CMYK</font></color>",
|
34
|
-
:inline_format => true)
|
35
|
-
|
36
|
-
file = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
|
37
|
-
pdf.font_families["Action Man"] = {
|
38
|
-
:normal => { :file => file, :font => "ActionMan" },
|
39
|
-
:italic => { :file => file, :font => "ActionMan-Italic" },
|
40
|
-
:bold => { :file => file, :font => "ActionMan-Bold" },
|
41
|
-
:bold_italic => { :file => file, :font => "ActionMan-BoldItalic" }
|
42
|
-
}
|
43
|
-
|
44
|
-
pdf.font("Action Man")
|
45
|
-
pdf.text("\nhello <b>world\nhow <i>are</i></b> you?",
|
46
|
-
:inline_format => true)
|
47
|
-
|
48
|
-
|
49
|
-
pdf.font("Helvetica")
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
class Highlight
|
54
|
-
def initialize(options)
|
55
|
-
@color = options[:color]
|
56
|
-
@document = options[:document]
|
57
|
-
end
|
58
|
-
|
59
|
-
def render_behind(fragment)
|
60
|
-
original_color = @document.fill_color
|
61
|
-
@document.fill_color = @color
|
62
|
-
@document.fill_rectangle(fragment.top_left,
|
63
|
-
fragment.width,
|
64
|
-
fragment.height)
|
65
|
-
@document.fill_color = original_color
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class FragmentBorder
|
70
|
-
def initialize(options)
|
71
|
-
@radius = options[:radius]
|
72
|
-
@connect_corners = options[:connect_corners]
|
73
|
-
@document = options[:document]
|
74
|
-
end
|
75
|
-
|
76
|
-
def render_in_front(fragment)
|
77
|
-
box = fragment.bounding_box
|
78
|
-
if @connect_corners
|
79
|
-
@document.stroke_polygon(fragment.top_left, fragment.top_right,
|
80
|
-
fragment.bottom_right, fragment.bottom_left)
|
81
|
-
end
|
82
|
-
@document.stroke_circle(fragment.top_left, @radius)
|
83
|
-
@document.stroke_circle(fragment.top_right, @radius)
|
84
|
-
@document.stroke_circle(fragment.bottom_right, @radius)
|
85
|
-
@document.stroke_circle(fragment.bottom_left, @radius)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
highlight_callback = Highlight.new(:color => 'ffff00', :document => pdf)
|
90
|
-
border_callback = FragmentBorder.new(:radius => 2.5,
|
91
|
-
:connect_corners => true,
|
92
|
-
:document => pdf)
|
93
|
-
pdf.formatted_text([
|
94
|
-
{ :text => "\n" },
|
95
|
-
{ :text => "hello ",
|
96
|
-
:callback => highlight_callback },
|
97
|
-
{ :text => "world",
|
98
|
-
:size => 24,
|
99
|
-
:character_spacing => 0,
|
100
|
-
:callback => [highlight_callback, border_callback] },
|
101
|
-
{ :text => " hello" }
|
102
|
-
], :indent_paragraphs => 40, :character_spacing => -2)
|
103
|
-
end
|
104
|
-
|
data/examples/text/kerning.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Demonstration of enabling and disabling kerning support
|
4
|
-
#
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
-
%w[.. example_helper]))
|
7
|
-
|
8
|
-
Prawn::Document.generate "kerning.pdf" do
|
9
|
-
draw_text "To kern?", :at => [200,720], :size => 24, :kerning => true
|
10
|
-
draw_text "To not kern?", :at => [200,690], :size => 24, :kerning => false
|
11
|
-
|
12
|
-
move_down 100
|
13
|
-
|
14
|
-
pad(30) do
|
15
|
-
text "To kern and wrap. " * 5, :size => 24, :kerning => true
|
16
|
-
end
|
17
|
-
|
18
|
-
text "To not kern and wrap. " * 5, :size => 24, :kerning => false
|
19
|
-
|
20
|
-
font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
21
|
-
|
22
|
-
draw_text "To kern?", :at => [200,660], :size => 24, :kerning => true
|
23
|
-
draw_text "To not kern?", :at => [200,630], :size => 24, :kerning => false
|
24
|
-
|
25
|
-
pad(30) do
|
26
|
-
text "To kern and wrap. " * 5, :size => 24, :kerning => true
|
27
|
-
end
|
28
|
-
|
29
|
-
text "To not kern and wrap. " * 5, :size => 24, :kerning => false
|
30
|
-
|
31
|
-
end
|
@@ -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
|