prawn-graph 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +3 -0
- data/Rakefile +34 -0
- data/examples/example_helper.rb +10 -0
- data/examples/graph/advanced_bar_chart.rb +22 -0
- data/examples/graph/bar_chart.rb +18 -0
- data/examples/graph/line_chart.rb +18 -0
- data/lib/prawn/graph.rb +94 -0
- data/lib/prawn/graph/bar.rb +172 -0
- data/lib/prawn/graph/chart.rb +4 -0
- data/lib/prawn/graph/errors.rb +6 -0
- data/lib/prawn/graph/grid.rb +43 -0
- data/lib/prawn/graph/line.rb +43 -0
- data/vendor/prawn-core/COPYING +340 -0
- data/vendor/prawn-core/HACKING +46 -0
- data/vendor/prawn-core/LICENSE +56 -0
- data/vendor/prawn-core/README +138 -0
- data/vendor/prawn-core/Rakefile +75 -0
- data/vendor/prawn-core/bench/afm_text_bench.rb +18 -0
- data/vendor/prawn-core/bench/png_type_6.rb +15 -0
- data/vendor/prawn-core/bench/ttf_text_bench.rb +19 -0
- data/vendor/prawn-core/bugs/indentation_across_pagebreaks.rb +15 -0
- data/vendor/prawn-core/bugs/resolved/canvas_sets_y_to_0.rb +15 -0
- data/vendor/prawn-core/bugs/resolved/png_barcode_issue.rb +11 -0
- data/vendor/prawn-core/bugs/resolved/transaction_page_number_issue_79.rb +21 -0
- data/vendor/prawn-core/bugs/resolved/ttf_fails_in_transactions.rb +24 -0
- data/vendor/prawn-core/data/encodings/win_ansi.txt +29 -0
- data/vendor/prawn-core/data/fonts/Action Man.dfont +0 -0
- data/vendor/prawn-core/data/fonts/Activa.ttf +0 -0
- data/vendor/prawn-core/data/fonts/Chalkboard.ttf +0 -0
- data/vendor/prawn-core/data/fonts/Courier-Bold.afm +342 -0
- data/vendor/prawn-core/data/fonts/Courier-BoldOblique.afm +342 -0
- data/vendor/prawn-core/data/fonts/Courier-Oblique.afm +342 -0
- data/vendor/prawn-core/data/fonts/Courier.afm +342 -0
- data/vendor/prawn-core/data/fonts/DejaVuSans.ttf +0 -0
- data/vendor/prawn-core/data/fonts/Dustismo_Roman.ttf +0 -0
- data/vendor/prawn-core/data/fonts/Helvetica-Bold.afm +2827 -0
- data/vendor/prawn-core/data/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/vendor/prawn-core/data/fonts/Helvetica-Oblique.afm +3051 -0
- data/vendor/prawn-core/data/fonts/Helvetica.afm +3051 -0
- data/vendor/prawn-core/data/fonts/MustRead.html +19 -0
- data/vendor/prawn-core/data/fonts/Symbol.afm +213 -0
- data/vendor/prawn-core/data/fonts/Times-Bold.afm +2588 -0
- data/vendor/prawn-core/data/fonts/Times-BoldItalic.afm +2384 -0
- data/vendor/prawn-core/data/fonts/Times-Italic.afm +2667 -0
- data/vendor/prawn-core/data/fonts/Times-Roman.afm +2419 -0
- data/vendor/prawn-core/data/fonts/ZapfDingbats.afm +225 -0
- data/vendor/prawn-core/data/fonts/comicsans.ttf +0 -0
- data/vendor/prawn-core/data/fonts/gkai00mp.ttf +0 -0
- data/vendor/prawn-core/data/images/16bit.alpha +0 -0
- data/vendor/prawn-core/data/images/16bit.dat +0 -0
- data/vendor/prawn-core/data/images/16bit.png +0 -0
- data/vendor/prawn-core/data/images/arrow.png +0 -0
- data/vendor/prawn-core/data/images/arrow2.png +0 -0
- data/vendor/prawn-core/data/images/barcode_issue.png +0 -0
- data/vendor/prawn-core/data/images/dice.alpha +0 -0
- data/vendor/prawn-core/data/images/dice.dat +0 -0
- data/vendor/prawn-core/data/images/dice.png +0 -0
- data/vendor/prawn-core/data/images/dice_interlaced.png +0 -0
- data/vendor/prawn-core/data/images/fractal.jpg +0 -0
- data/vendor/prawn-core/data/images/letterhead.jpg +0 -0
- data/vendor/prawn-core/data/images/page_white_text.alpha +0 -0
- data/vendor/prawn-core/data/images/page_white_text.dat +0 -0
- data/vendor/prawn-core/data/images/page_white_text.png +0 -0
- data/vendor/prawn-core/data/images/pigs.jpg +0 -0
- data/vendor/prawn-core/data/images/rails.dat +0 -0
- data/vendor/prawn-core/data/images/rails.png +0 -0
- data/vendor/prawn-core/data/images/ruport.png +0 -0
- data/vendor/prawn-core/data/images/ruport_data.dat +0 -0
- data/vendor/prawn-core/data/images/ruport_transparent.png +0 -0
- data/vendor/prawn-core/data/images/ruport_type0.png +0 -0
- data/vendor/prawn-core/data/images/stef.jpg +0 -0
- data/vendor/prawn-core/data/images/tru256.bmp +0 -0
- data/vendor/prawn-core/data/images/web-links.dat +1 -0
- data/vendor/prawn-core/data/images/web-links.png +0 -0
- data/vendor/prawn-core/data/shift_jis_text.txt +1 -0
- data/vendor/prawn-core/examples/bounding_box/bounding_boxes.rb +43 -0
- data/vendor/prawn-core/examples/bounding_box/indentation.rb +34 -0
- data/vendor/prawn-core/examples/bounding_box/russian_boxes.rb +36 -0
- data/vendor/prawn-core/examples/bounding_box/stretched_nesting.rb +67 -0
- data/vendor/prawn-core/examples/column_box/column_box_example.rb +43 -0
- data/vendor/prawn-core/examples/example_helper.rb +3 -0
- data/vendor/prawn-core/examples/general/background.rb +23 -0
- data/vendor/prawn-core/examples/general/canvas.rb +15 -0
- data/vendor/prawn-core/examples/general/context_sensitive_headers.rb +37 -0
- data/vendor/prawn-core/examples/general/float.rb +11 -0
- data/vendor/prawn-core/examples/general/margin.rb +36 -0
- data/vendor/prawn-core/examples/general/measurement_units.rb +51 -0
- data/vendor/prawn-core/examples/general/metadata-info.rb +16 -0
- data/vendor/prawn-core/examples/general/multi_page_layout.rb +18 -0
- data/vendor/prawn-core/examples/general/outlines.rb +50 -0
- data/vendor/prawn-core/examples/general/page_geometry.rb +31 -0
- data/vendor/prawn-core/examples/general/page_numbering.rb +15 -0
- data/vendor/prawn-core/examples/general/repeaters.rb +47 -0
- data/vendor/prawn-core/examples/general/stamp.rb +41 -0
- data/vendor/prawn-core/examples/graphics/basic_images.rb +23 -0
- data/vendor/prawn-core/examples/graphics/cmyk.rb +12 -0
- data/vendor/prawn-core/examples/graphics/curves.rb +11 -0
- data/vendor/prawn-core/examples/graphics/hexagon.rb +13 -0
- data/vendor/prawn-core/examples/graphics/image_fit.rb +15 -0
- data/vendor/prawn-core/examples/graphics/image_flow.rb +37 -0
- data/vendor/prawn-core/examples/graphics/image_position.rb +17 -0
- data/vendor/prawn-core/examples/graphics/line.rb +32 -0
- data/vendor/prawn-core/examples/graphics/png_types.rb +22 -0
- data/vendor/prawn-core/examples/graphics/polygons.rb +16 -0
- data/vendor/prawn-core/examples/graphics/remote_images.rb +12 -0
- data/vendor/prawn-core/examples/graphics/rounded_polygons.rb +19 -0
- data/vendor/prawn-core/examples/graphics/rounded_rectangle.rb +20 -0
- data/vendor/prawn-core/examples/graphics/ruport_style_helpers.rb +19 -0
- data/vendor/prawn-core/examples/graphics/stroke_bounds.rb +20 -0
- data/vendor/prawn-core/examples/graphics/stroke_cap_and_join.rb +45 -0
- data/vendor/prawn-core/examples/graphics/stroke_dash.rb +42 -0
- data/vendor/prawn-core/examples/graphics/transformations.rb +52 -0
- data/vendor/prawn-core/examples/graphics/transparency.rb +26 -0
- data/vendor/prawn-core/examples/m17n/chinese_text_wrapping.rb +17 -0
- data/vendor/prawn-core/examples/m17n/euro.rb +15 -0
- data/vendor/prawn-core/examples/m17n/sjis.rb +28 -0
- data/vendor/prawn-core/examples/m17n/utf8.rb +13 -0
- data/vendor/prawn-core/examples/m17n/win_ansi_charset.rb +54 -0
- data/vendor/prawn-core/examples/text/alignment.rb +18 -0
- data/vendor/prawn-core/examples/text/dfont.rb +48 -0
- data/vendor/prawn-core/examples/text/family_based_styling.rb +24 -0
- data/vendor/prawn-core/examples/text/font_calculations.rb +91 -0
- data/vendor/prawn-core/examples/text/font_size.rb +33 -0
- data/vendor/prawn-core/examples/text/indent_paragraphs.rb +18 -0
- data/vendor/prawn-core/examples/text/kerning.rb +30 -0
- data/vendor/prawn-core/examples/text/rotated.rb +98 -0
- data/vendor/prawn-core/examples/text/simple_text.rb +17 -0
- data/vendor/prawn-core/examples/text/simple_text_ttf.rb +17 -0
- data/vendor/prawn-core/examples/text/span.rb +29 -0
- data/vendor/prawn-core/examples/text/text_box.rb +88 -0
- data/vendor/prawn-core/examples/text/text_box_returning_excess.rb +51 -0
- data/vendor/prawn-core/examples/text/text_flow.rb +67 -0
- data/vendor/prawn-core/lib/prawn/byte_string.rb +7 -0
- data/vendor/prawn-core/lib/prawn/compatibility.rb +51 -0
- data/vendor/prawn-core/lib/prawn/core.rb +87 -0
- data/vendor/prawn-core/lib/prawn/core/page.rb +88 -0
- data/vendor/prawn-core/lib/prawn/core/text.rb +65 -0
- data/vendor/prawn-core/lib/prawn/document.rb +596 -0
- data/vendor/prawn-core/lib/prawn/document/annotations.rb +65 -0
- data/vendor/prawn-core/lib/prawn/document/bounding_box.rb +402 -0
- data/vendor/prawn-core/lib/prawn/document/column_box.rb +113 -0
- data/vendor/prawn-core/lib/prawn/document/destinations.rb +92 -0
- data/vendor/prawn-core/lib/prawn/document/graphics_state.rb +49 -0
- data/vendor/prawn-core/lib/prawn/document/internals.rb +153 -0
- data/vendor/prawn-core/lib/prawn/document/page_geometry.rb +136 -0
- data/vendor/prawn-core/lib/prawn/document/snapshot.rb +80 -0
- data/vendor/prawn-core/lib/prawn/document/span.rb +55 -0
- data/vendor/prawn-core/lib/prawn/encoding.rb +121 -0
- data/vendor/prawn-core/lib/prawn/errors.rb +83 -0
- data/vendor/prawn-core/lib/prawn/font.rb +329 -0
- data/vendor/prawn-core/lib/prawn/font/afm.rb +217 -0
- data/vendor/prawn-core/lib/prawn/font/dfont.rb +34 -0
- data/vendor/prawn-core/lib/prawn/font/ttf.rb +341 -0
- data/vendor/prawn-core/lib/prawn/graphics.rb +321 -0
- data/vendor/prawn-core/lib/prawn/graphics/cap_style.rb +38 -0
- data/vendor/prawn-core/lib/prawn/graphics/color.rb +205 -0
- data/vendor/prawn-core/lib/prawn/graphics/dash.rb +71 -0
- data/vendor/prawn-core/lib/prawn/graphics/join_style.rb +38 -0
- data/vendor/prawn-core/lib/prawn/graphics/transformation.rb +157 -0
- data/vendor/prawn-core/lib/prawn/graphics/transparency.rb +99 -0
- data/vendor/prawn-core/lib/prawn/images.rb +337 -0
- data/vendor/prawn-core/lib/prawn/images/jpg.rb +46 -0
- data/vendor/prawn-core/lib/prawn/images/png.rb +219 -0
- data/vendor/prawn-core/lib/prawn/literal_string.rb +14 -0
- data/vendor/prawn-core/lib/prawn/measurement_extensions.rb +46 -0
- data/vendor/prawn-core/lib/prawn/measurements.rb +71 -0
- data/vendor/prawn-core/lib/prawn/name_tree.rb +166 -0
- data/vendor/prawn-core/lib/prawn/object_store.rb +93 -0
- data/vendor/prawn-core/lib/prawn/outline.rb +278 -0
- data/vendor/prawn-core/lib/prawn/pdf_object.rb +83 -0
- data/vendor/prawn-core/lib/prawn/reference.rb +92 -0
- data/vendor/prawn-core/lib/prawn/repeater.rb +129 -0
- data/vendor/prawn-core/lib/prawn/stamp.rb +128 -0
- data/vendor/prawn-core/lib/prawn/text.rb +271 -0
- data/vendor/prawn-core/lib/prawn/text/box.rb +414 -0
- data/vendor/prawn-core/meta/Rakefile +36 -0
- data/vendor/prawn-core/meta/lib/prawn.rb +2 -0
- data/vendor/prawn-core/reference_pdfs/alignment.pdf +229 -0
- data/vendor/prawn-core/reference_pdfs/background.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/basic_images.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/bounding_boxes.pdf +128 -0
- data/vendor/prawn-core/reference_pdfs/canvas.pdf +78 -0
- data/vendor/prawn-core/reference_pdfs/chinese_flow.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/cmyk.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/column_box.pdf +3671 -0
- data/vendor/prawn-core/reference_pdfs/context_sensitive_headers.pdf +2331 -0
- data/vendor/prawn-core/reference_pdfs/curves.pdf +62 -0
- data/vendor/prawn-core/reference_pdfs/dfont.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/euro.pdf +75 -0
- data/vendor/prawn-core/reference_pdfs/family_style.pdf +286 -0
- data/vendor/prawn-core/reference_pdfs/flow.pdf +964 -0
- data/vendor/prawn-core/reference_pdfs/font_calculations.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/font_size.pdf +142 -0
- data/vendor/prawn-core/reference_pdfs/hexagon.pdf +61 -0
- data/vendor/prawn-core/reference_pdfs/image-flow.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/image_fit.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/image_position.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/indentation.pdf +124 -0
- data/vendor/prawn-core/reference_pdfs/kerning.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/landscape_a4.pdf +52 -0
- data/vendor/prawn-core/reference_pdfs/landscape_legal.pdf +52 -0
- data/vendor/prawn-core/reference_pdfs/landscape_letter.pdf +52 -0
- data/vendor/prawn-core/reference_pdfs/lines.pdf +116 -0
- data/vendor/prawn-core/reference_pdfs/margin.pdf +3850 -0
- data/vendor/prawn-core/reference_pdfs/measurement_units.pdf +4667 -0
- data/vendor/prawn-core/reference_pdfs/metadata-info.pdf +88 -0
- data/vendor/prawn-core/reference_pdfs/multi-layout.pdf +209 -0
- data/vendor/prawn-core/reference_pdfs/page_with_numbering.pdf +156 -0
- data/vendor/prawn-core/reference_pdfs/png_types.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/portrait_a4.pdf +52 -0
- data/vendor/prawn-core/reference_pdfs/portrait_legal.pdf +52 -0
- data/vendor/prawn-core/reference_pdfs/portrait_letter.pdf +52 -0
- data/vendor/prawn-core/reference_pdfs/pretty_polygons.pdf +122 -0
- data/vendor/prawn-core/reference_pdfs/remote_images.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/ruport.pdf +101 -0
- data/vendor/prawn-core/reference_pdfs/russian_boxes.pdf +2780 -0
- data/vendor/prawn-core/reference_pdfs/simple_text.pdf +136 -0
- data/vendor/prawn-core/reference_pdfs/simple_text_ttf.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/sjis.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/span.pdf +1975 -0
- data/vendor/prawn-core/reference_pdfs/stamp.pdf +649 -0
- data/vendor/prawn-core/reference_pdfs/stretched_nesting.pdf +200 -0
- data/vendor/prawn-core/reference_pdfs/stroke_bounds.pdf +135 -0
- data/vendor/prawn-core/reference_pdfs/stroke_cap_and_join.pdf +80 -0
- data/vendor/prawn-core/reference_pdfs/stroke_dash.pdf +457 -0
- data/vendor/prawn-core/reference_pdfs/text_box.pdf +962 -0
- data/vendor/prawn-core/reference_pdfs/text_box_returning_excess.pdf +271 -0
- data/vendor/prawn-core/reference_pdfs/transparency.pdf +347 -0
- data/vendor/prawn-core/reference_pdfs/utf8.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/win-ansi.pdf +6172 -0
- data/vendor/prawn-core/spec/annotations_spec.rb +90 -0
- data/vendor/prawn-core/spec/bounding_box_spec.rb +185 -0
- data/vendor/prawn-core/spec/destinations_spec.rb +15 -0
- data/vendor/prawn-core/spec/document_spec.rb +408 -0
- data/vendor/prawn-core/spec/font_spec.rb +314 -0
- data/vendor/prawn-core/spec/graphics_spec.rb +438 -0
- data/vendor/prawn-core/spec/images_spec.rb +79 -0
- data/vendor/prawn-core/spec/jpg_spec.rb +25 -0
- data/vendor/prawn-core/spec/measurement_units_spec.rb +23 -0
- data/vendor/prawn-core/spec/name_tree_spec.rb +112 -0
- data/vendor/prawn-core/spec/object_store_spec.rb +75 -0
- data/vendor/prawn-core/spec/outline_spec.rb +229 -0
- data/vendor/prawn-core/spec/pdf_object_spec.rb +122 -0
- data/vendor/prawn-core/spec/png_spec.rb +236 -0
- data/vendor/prawn-core/spec/reference_spec.rb +82 -0
- data/vendor/prawn-core/spec/repeater_spec.rb +96 -0
- data/vendor/prawn-core/spec/snapshot_spec.rb +138 -0
- data/vendor/prawn-core/spec/span_spec.rb +49 -0
- data/vendor/prawn-core/spec/spec_helper.rb +24 -0
- data/vendor/prawn-core/spec/stamp_spec.rb +108 -0
- data/vendor/prawn-core/spec/stroke_styles_spec.rb +152 -0
- data/vendor/prawn-core/spec/text_at_spec.rb +119 -0
- data/vendor/prawn-core/spec/text_box_spec.rb +603 -0
- data/vendor/prawn-core/spec/text_spec.rb +308 -0
- data/vendor/prawn-core/spec/transparency_spec.rb +75 -0
- data/vendor/prawn-core/vendor/pdf-inspector/README +18 -0
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector.rb +26 -0
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/extgstate.rb +18 -0
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/graphics.rb +131 -0
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/page.rb +25 -0
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/text.rb +31 -0
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/xobject.rb +19 -0
- data/vendor/prawn-core/vendor/ttfunk/data/fonts/DejaVuSans.ttf +0 -0
- data/vendor/prawn-core/vendor/ttfunk/data/fonts/comicsans.ttf +0 -0
- data/vendor/prawn-core/vendor/ttfunk/example.rb +45 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk.rb +102 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/directory.rb +17 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/encoding/mac_roman.rb +88 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/encoding/windows_1252.rb +69 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/reader.rb +44 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/resource_file.rb +78 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset.rb +18 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/base.rb +141 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb +46 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/unicode.rb +48 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/unicode_8bit.rb +63 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/windows_1252.rb +51 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset_collection.rb +72 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table.rb +46 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap.rb +34 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/format00.rb +54 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/format04.rb +126 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/subtable.rb +79 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf.rb +64 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf/compound.rb +81 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf/simple.rb +37 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/head.rb +44 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/hhea.rb +41 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/hmtx.rb +47 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/kern.rb +79 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/kern/format0.rb +62 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/loca.rb +43 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/maxp.rb +40 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/name.rb +119 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/os2.rb +78 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post.rb +91 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format10.rb +43 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format20.rb +35 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format25.rb +23 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format30.rb +17 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format40.rb +17 -0
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/simple.rb +14 -0
- data/vendor/prawn-core/www/index.html +196 -0
- data/vendor/prawn-core/www/media/bounding_boxes.pdf +146 -0
- data/vendor/prawn-core/www/media/bounding_boxes.png +0 -0
- data/vendor/prawn-core/www/media/bounding_boxes_out.png +0 -0
- data/vendor/prawn-core/www/media/fancy_table.pdf +350 -0
- data/vendor/prawn-core/www/media/image.pdf +0 -0
- data/vendor/prawn-core/www/media/images.png +0 -0
- data/vendor/prawn-core/www/media/prawn_logo.png +0 -0
- data/vendor/prawn-core/www/media/tables.png +0 -0
- data/vendor/prawn-core/www/media/utf8.pdf +0 -0
- data/vendor/prawn-core/www/media/utf8.png +0 -0
- data/vendor/prawn-core/www/prawn-Chinese.html +113 -0
- data/vendor/prawn-core/www/prawn.css +86 -0
- data/vendor/prawn-core/www/twilight.css +266 -0
- metadata +374 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# reference.rb : Implementation of PDF indirect objects
|
4
|
+
#
|
5
|
+
# Copyright April 2008, Gregory Brown. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
+
|
9
|
+
require 'zlib'
|
10
|
+
|
11
|
+
module Prawn
|
12
|
+
|
13
|
+
class Reference #:nodoc:
|
14
|
+
|
15
|
+
attr_accessor :gen, :data, :offset, :stream, :live, :identifier
|
16
|
+
|
17
|
+
def initialize(id, data)
|
18
|
+
@identifier = id
|
19
|
+
@gen = 0
|
20
|
+
@data = data
|
21
|
+
@compressed = false
|
22
|
+
@stream = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def object
|
26
|
+
output = "#{@identifier} #{gen} obj\n" <<
|
27
|
+
Prawn::PdfObject(data) << "\n"
|
28
|
+
if @stream
|
29
|
+
output << "stream\n" << @stream << "\nendstream\n"
|
30
|
+
end
|
31
|
+
output << "endobj\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
def <<(data)
|
35
|
+
raise 'Cannot add data to a stream that is compressed' if @compressed
|
36
|
+
(@stream ||= "") << data
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
"#{@identifier} #{gen} R"
|
41
|
+
end
|
42
|
+
|
43
|
+
def compress_stream
|
44
|
+
@stream = Zlib::Deflate.deflate(@stream)
|
45
|
+
@data[:Filter] = :FlateDecode
|
46
|
+
@data[:Length] ||= @stream.length
|
47
|
+
@compressed = true
|
48
|
+
end
|
49
|
+
|
50
|
+
def compressed?
|
51
|
+
@compressed
|
52
|
+
end
|
53
|
+
|
54
|
+
# Replaces the data and stream with that of other_ref. Preserves compressed
|
55
|
+
# status.
|
56
|
+
def replace(other_ref)
|
57
|
+
@data = other_ref.data
|
58
|
+
@stream = other_ref.stream
|
59
|
+
@compressed = other_ref.compressed?
|
60
|
+
end
|
61
|
+
|
62
|
+
# Marks this and all referenced objects live, recursively.
|
63
|
+
def mark_live
|
64
|
+
return if @live
|
65
|
+
@live = true
|
66
|
+
referenced_objects.each { |o| o.mark_live }
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
# All objects referenced by this one. Used for GC.
|
72
|
+
def referenced_objects(obj=@data)
|
73
|
+
case obj
|
74
|
+
when Reference
|
75
|
+
[]
|
76
|
+
when Hash
|
77
|
+
obj.values.map{|v| [v] + referenced_objects(v) }
|
78
|
+
when Array
|
79
|
+
obj.map{|v| [v] + referenced_objects(v) }
|
80
|
+
else []
|
81
|
+
end.flatten.grep(Reference)
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
module_function
|
87
|
+
|
88
|
+
def Reference(*args, &block) #:nodoc:
|
89
|
+
Reference.new(*args, &block)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# repeater.rb : Implements repeated page elements.
|
4
|
+
# Heavy inspired by repeating_element() in PDF::Wrapper
|
5
|
+
# http://pdf-wrapper.rubyforge.org/
|
6
|
+
#
|
7
|
+
# Copyright November 2009, Gregory Brown. All Rights Reserved.
|
8
|
+
#
|
9
|
+
# This is free software. Please see the LICENSE and COPYING files for details.
|
10
|
+
|
11
|
+
module Prawn
|
12
|
+
|
13
|
+
class Document
|
14
|
+
|
15
|
+
# A list of all repeaters in the document.
|
16
|
+
# See Document#repeat for details
|
17
|
+
#
|
18
|
+
def repeaters
|
19
|
+
@repeaters ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
# Provides a way to execute a block of code repeatedly based on a
|
23
|
+
# page_filter. Since Stamp is used under the hood, this method is very space
|
24
|
+
# efficient.
|
25
|
+
#
|
26
|
+
# Available page filters are:
|
27
|
+
# :all -- repeats on every page
|
28
|
+
# :odd -- repeats on odd pages
|
29
|
+
# :even -- repeats on even pages
|
30
|
+
# some_array -- repeats on every page listed in the array
|
31
|
+
# some_range -- repeats on every page included in the range
|
32
|
+
# some_lambda -- yields page number and repeats for true return values
|
33
|
+
#
|
34
|
+
# Also accepts an optional second argument for dynamic content which executes the code
|
35
|
+
# in the context of the filtered pages without using a Stamp.
|
36
|
+
#
|
37
|
+
# Example:
|
38
|
+
#
|
39
|
+
# Prawn::Document.generate("repeat.pdf", :skip_page_creation => true) do
|
40
|
+
#
|
41
|
+
# repeat :all do
|
42
|
+
# draw_text "ALLLLLL", :at => bounds.top_left
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# repeat :odd do
|
46
|
+
# draw_text "ODD", :at => [0,0]
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# repeat :even do
|
50
|
+
# draw_text "EVEN", :at => [0,0]
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# repeat [1,2] do
|
54
|
+
# draw_text "[1,2]", :at => [100,0]
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# repeat 2..4 do
|
58
|
+
# draw_text "2..4", :at => [200,0]
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# repeat(lambda { |pg| pg % 3 == 0 }) do
|
62
|
+
# draw_text "Every third", :at => [250, 20]
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# 10.times do
|
66
|
+
# start_new_page
|
67
|
+
# draw_text "A wonderful page", :at => [400,400]
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# repeat(:all, :dynamic => true) do
|
71
|
+
# text page_number, :at => [500, 0]
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
def repeat(page_filter, options={}, &block)
|
77
|
+
repeaters << Prawn::Repeater.new(self, page_filter, !!options[:dynamic], &block)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class Repeater #:nodoc:
|
82
|
+
class << self
|
83
|
+
attr_writer :count
|
84
|
+
|
85
|
+
def count
|
86
|
+
@count ||= 0
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
attr_reader :name
|
91
|
+
|
92
|
+
def initialize(document, page_filter, dynamic = false, &block)
|
93
|
+
@document = document
|
94
|
+
@page_filter = page_filter
|
95
|
+
@dynamic = dynamic
|
96
|
+
@stamp_name = "prawn_repeater(#{Repeater.count})"
|
97
|
+
@document.create_stamp(@stamp_name, &block) unless dynamic
|
98
|
+
@block = block if dynamic
|
99
|
+
|
100
|
+
Repeater.count += 1
|
101
|
+
end
|
102
|
+
|
103
|
+
def match?(page_number)
|
104
|
+
case @page_filter
|
105
|
+
when :all
|
106
|
+
true
|
107
|
+
when :odd
|
108
|
+
page_number % 2 == 1
|
109
|
+
when :even
|
110
|
+
page_number % 2 == 0
|
111
|
+
when Range, Array
|
112
|
+
@page_filter.include?(page_number)
|
113
|
+
when Proc
|
114
|
+
@page_filter.call(page_number)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def run(page_number)
|
119
|
+
if !@dynamic
|
120
|
+
@document.stamp(@stamp_name) if match?(page_number)
|
121
|
+
elsif @block
|
122
|
+
@block.arity < 1 ? @document.instance_eval(&@block) : @block[@document]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# stamp.rb : Implements a repeatable stamp
|
4
|
+
#
|
5
|
+
# Copyright October 2009, Daniel Nelson. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
+
#
|
9
|
+
|
10
|
+
module Prawn
|
11
|
+
|
12
|
+
# The Prawn::Stamp module is used to create content that will be
|
13
|
+
# included multiple times in a document. Using a stamp has three
|
14
|
+
# advantages over creating content anew each time it is placed on
|
15
|
+
# the page:
|
16
|
+
# i. faster document creation
|
17
|
+
# ii. smaller final document
|
18
|
+
# iii. faster display on subsequent displays of the repeated
|
19
|
+
# element because the viewer application can cache the rendered
|
20
|
+
# results
|
21
|
+
#
|
22
|
+
# Example:
|
23
|
+
# pdf.create_stamp("my_stamp") {
|
24
|
+
# pdf.fill_circle_at([10, 15], :radius => 5)
|
25
|
+
# pdf.draw_text("hello world", :at => [20, 10])
|
26
|
+
# }
|
27
|
+
# pdf.stamp("my_stamp")
|
28
|
+
#
|
29
|
+
module Stamp
|
30
|
+
|
31
|
+
# Renders the stamp named <tt>name</tt> to the page
|
32
|
+
# raises <tt>Prawn::Errors::InvalidName</tt> if name.empty?
|
33
|
+
# raises <tt>Prawn::Errors::UndefinedObjectName</tt> if no stamp
|
34
|
+
# has been created with this name
|
35
|
+
#
|
36
|
+
# Example:
|
37
|
+
# pdf.create_stamp("my_stamp") {
|
38
|
+
# pdf.fill_circle_at([10, 15], :radius => 5)
|
39
|
+
# pdf.text("hello world", :at => [20, 10])
|
40
|
+
# }
|
41
|
+
# pdf.stamp("my_stamp")
|
42
|
+
#
|
43
|
+
def stamp(name)
|
44
|
+
dictionary_name, dictionary = stamp_dictionary(name)
|
45
|
+
add_content "/#{dictionary_name} Do"
|
46
|
+
page.xobjects.merge!(dictionary_name => dictionary)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Renders the stamp named <tt>name</tt> at a position offset from
|
50
|
+
# the initial coords at which the elements of the stamp was
|
51
|
+
# created
|
52
|
+
#
|
53
|
+
# Example:
|
54
|
+
# pdf.create_stamp("circle") do
|
55
|
+
# pdf.fill_circle_at([0, 0], :radius => 25)
|
56
|
+
# end
|
57
|
+
# # draws a circle at 100, 100
|
58
|
+
# pdf.stamp_at("circle", [100, 100])
|
59
|
+
#
|
60
|
+
# See stamp() for exceptions that might be raised
|
61
|
+
#
|
62
|
+
def stamp_at(name, point)
|
63
|
+
translate(point[0], point[1]) { stamp(name) }
|
64
|
+
end
|
65
|
+
|
66
|
+
# Creates a re-usable stamp named <tt>name</tt>
|
67
|
+
#
|
68
|
+
# raises <tt>Prawn::Errors::NameTaken</tt> if a stamp already
|
69
|
+
# exists in this document with this name
|
70
|
+
# raises <tt>Prawn::Errors::InvalidName</tt> if name.empty?
|
71
|
+
#
|
72
|
+
# Example:
|
73
|
+
# pdf.create_stamp("my_stamp") {
|
74
|
+
# pdf.fill_circle_at([10, 15], :radius => 5)
|
75
|
+
# pdf.draw_text("hello world", :at => [20, 10])
|
76
|
+
# }
|
77
|
+
#
|
78
|
+
def create_stamp(name, &block)
|
79
|
+
dictionary = create_stamp_dictionary(name)
|
80
|
+
|
81
|
+
page.stamp_stream(dictionary, &block)
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def stamp_dictionary_registry
|
87
|
+
@stamp_dictionary_registry ||= {}
|
88
|
+
end
|
89
|
+
|
90
|
+
def next_stamp_dictionary_id
|
91
|
+
stamp_dictionary_registry.length + 1
|
92
|
+
end
|
93
|
+
|
94
|
+
def stamp_dictionary(name)
|
95
|
+
raise Prawn::Errors::InvalidName if name.empty?
|
96
|
+
if stamp_dictionary_registry[name].nil?
|
97
|
+
raise Prawn::Errors::UndefinedObjectName
|
98
|
+
end
|
99
|
+
|
100
|
+
dict = stamp_dictionary_registry[name]
|
101
|
+
|
102
|
+
dictionary_name = dict[:stamp_dictionary_name]
|
103
|
+
dictionary = dict[:stamp_dictionary]
|
104
|
+
[dictionary_name, dictionary]
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_stamp_dictionary(name)
|
108
|
+
raise Prawn::Errors::InvalidName if name.empty?
|
109
|
+
raise Prawn::Errors::NameTaken unless stamp_dictionary_registry[name].nil?
|
110
|
+
# BBox origin is the lower left margin of the page, so we need
|
111
|
+
# it to be the full dimension of the page, or else things that
|
112
|
+
# should appear near the top or right margin are invisible
|
113
|
+
dictionary = ref!(:Type => :XObject,
|
114
|
+
:Subtype => :Form,
|
115
|
+
:BBox => [0, 0,
|
116
|
+
page.dimensions[2], page.dimensions[3]])
|
117
|
+
|
118
|
+
dictionary_name = "Stamp#{next_stamp_dictionary_id}"
|
119
|
+
|
120
|
+
stamp_dictionary_registry[name] = {
|
121
|
+
:stamp_dictionary_name => dictionary_name,
|
122
|
+
:stamp_dictionary => dictionary
|
123
|
+
}
|
124
|
+
dictionary
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,271 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# text.rb : Implements PDF text primitives
|
4
|
+
#
|
5
|
+
# Copyright May 2008, Gregory Brown. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
+
require "prawn/core/text"
|
9
|
+
require "prawn/text/box"
|
10
|
+
require "zlib"
|
11
|
+
|
12
|
+
module Prawn
|
13
|
+
module Text
|
14
|
+
|
15
|
+
include Prawn::Core::Text
|
16
|
+
|
17
|
+
# Gets height of text in PDF points.
|
18
|
+
# Same options as text(), except as noted.
|
19
|
+
# Not compatible with :indent_paragraphs option
|
20
|
+
#
|
21
|
+
# Raises <tt>Prawn::Errors::UnknownOption</tt> if
|
22
|
+
# <tt>:indent_paragraphs</tt> option included and debug flag is set
|
23
|
+
#
|
24
|
+
def height_of(string, options={})
|
25
|
+
process_final_gap_option(options)
|
26
|
+
box = Text::Box.new(string,
|
27
|
+
options.merge(:height => 100000000,
|
28
|
+
:document => self))
|
29
|
+
box.render(:dry_run => true)
|
30
|
+
height = box.height - box.descender
|
31
|
+
height += box.line_height + box.leading - box.ascender if @final_gap
|
32
|
+
height
|
33
|
+
end
|
34
|
+
|
35
|
+
# If you want text to flow onto a new page or between columns, this is the
|
36
|
+
# method to use. If, instead, if you want to place bounded text outside of
|
37
|
+
# the flow of a document (for captions, labels, charts, etc.), use Text::Box
|
38
|
+
# or its convenience method text_box.
|
39
|
+
#
|
40
|
+
# Draws text on the page. Prawn attempts to wrap the text to fit within your
|
41
|
+
# current bounding box (or margin_box if no bounding box is being used).
|
42
|
+
# Text will flow onto the next page when it reaches the bottom of the
|
43
|
+
# bounding box. Text wrap in Prawn does not re-flow linebreaks, so if you
|
44
|
+
# want fully automated text wrapping, be sure to remove newlines before
|
45
|
+
# attempting to draw your string.
|
46
|
+
#
|
47
|
+
# pdf.text "Will be wrapped when it hits the edge of your bounding box"
|
48
|
+
# pdf.text "This will be centered", :align => :center
|
49
|
+
# pdf.text "This will be right aligned", :align => :right
|
50
|
+
#
|
51
|
+
# If your font contains kerning pairs data that Prawn can parse, the
|
52
|
+
# text will be kerned by default. You can disable this feature by passing
|
53
|
+
# <tt>:kerning => false</tt>.
|
54
|
+
#
|
55
|
+
# === Text Positioning Details:
|
56
|
+
#
|
57
|
+
# The text is positioned at font.ascender below the baseline,
|
58
|
+
# making it easy to use this method within bounding boxes and spans.
|
59
|
+
#
|
60
|
+
# == Encoding
|
61
|
+
#
|
62
|
+
# Note that strings passed to this function should be encoded as UTF-8.
|
63
|
+
# If you get unexpected characters appearing in your rendered document,
|
64
|
+
# check this.
|
65
|
+
#
|
66
|
+
# If the current font is a built-in one, although the string must be
|
67
|
+
# encoded as UTF-8, only characters that are available in WinAnsi
|
68
|
+
# are allowed.
|
69
|
+
#
|
70
|
+
# If an empty box is rendered to your PDF instead of the character you
|
71
|
+
# wanted it usually means the current font doesn't include that character.
|
72
|
+
#
|
73
|
+
# == Options (default values marked in [])
|
74
|
+
#
|
75
|
+
# <tt>:kerning</tt>:: <tt>boolean</tt>. Whether or not to use kerning (if it
|
76
|
+
# is available with the current font) [true]
|
77
|
+
# <tt>:size</tt>:: <tt>number</tt>. The font size to use. [current font
|
78
|
+
# size]
|
79
|
+
# <tt>:style</tt>:: The style to use. The requested style must be part of
|
80
|
+
# the current font familly. [current style]
|
81
|
+
# <tt>:indent_paragraphs</tt>:: <tt>number</tt>. The amount to indent the
|
82
|
+
# first line of each paragraph. Omit this
|
83
|
+
# option if you do not want indenting
|
84
|
+
# <tt>:align</tt>:: <tt>:left</tt>, <tt>:center</tt>, or <tt>:right</tt>.
|
85
|
+
# Alignment within the bounding box [:left]
|
86
|
+
# <tt>:valign</tt>:: <tt>:top</tt>, <tt>:center</tt>, or <tt>:bottom</tt>.
|
87
|
+
# Vertical alignment within the bounding box [:top]
|
88
|
+
# <tt>:leading</tt>:: <tt>number</tt>. Additional space between lines [0]
|
89
|
+
# <tt>:final_gap</tt>:: <tt>boolean</tt>. If true, then the space between
|
90
|
+
# each line is included below the last line;
|
91
|
+
# otherwise, document.y is placed just below the
|
92
|
+
# descender of the last line printed [true]
|
93
|
+
# <tt>:wrap_block</tt>:: <tt>proc</tt>. A proc used for custom line
|
94
|
+
# wrapping. The proc must accept a single
|
95
|
+
# <tt>line</tt> of text and an <tt>options</tt> hash
|
96
|
+
# and return the string from that single line that
|
97
|
+
# can fit on the line under the conditions defined by
|
98
|
+
# <tt>options</tt>. If omitted, the default wrapping
|
99
|
+
# proc is used. The options hash passed into the
|
100
|
+
# wrap_block proc includes the following options:
|
101
|
+
# <tt>:width</tt>:: the width available for the
|
102
|
+
# current line of text
|
103
|
+
# <tt>:document</tt>:: the pdf object
|
104
|
+
# <tt>:kerning</tt>:: boolean
|
105
|
+
# <tt>:size</tt>:: the font size
|
106
|
+
#
|
107
|
+
# Raises <tt>ArgumentError</tt> if <tt>:at</tt> option included
|
108
|
+
#
|
109
|
+
def text(string, options={})
|
110
|
+
# we modify the options. don't change the user's hash
|
111
|
+
options = options.dup
|
112
|
+
inspect_options_for_text(options)
|
113
|
+
|
114
|
+
if @indent_paragraphs
|
115
|
+
string.split("\n").each do |paragraph|
|
116
|
+
options[:skip_encoding] = false
|
117
|
+
remaining_text = draw_indented_line(paragraph, options)
|
118
|
+
options[:skip_encoding] = true
|
119
|
+
if remaining_text == paragraph
|
120
|
+
# we were too close to the bottom of the page to print even one line
|
121
|
+
@bounding_box.move_past_bottom
|
122
|
+
remaining_text = draw_indented_line(paragraph, options)
|
123
|
+
end
|
124
|
+
remaining_text = fill_text_box(remaining_text, options)
|
125
|
+
draw_remaining_text_on_new_pages(remaining_text, options)
|
126
|
+
end
|
127
|
+
else
|
128
|
+
remaining_text = fill_text_box(string, options)
|
129
|
+
options[:skip_encoding] = true
|
130
|
+
draw_remaining_text_on_new_pages(remaining_text, options)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Draws text on the page, beginning at the point specified by the :at option
|
135
|
+
# the string is assumed to be pre-formatted to properly fit the page.
|
136
|
+
#
|
137
|
+
# pdf.draw_text "Hello World", :at => [100,100]
|
138
|
+
# pdf.draw_text "Goodbye World", :at => [50,50], :size => 16
|
139
|
+
#
|
140
|
+
# If your font contains kerning pairs data that Prawn can parse, the
|
141
|
+
# text will be kerned by default. You can disable this feature by passing
|
142
|
+
# <tt>:kerning => false</tt>.
|
143
|
+
#
|
144
|
+
# === Text Positioning Details:
|
145
|
+
#
|
146
|
+
# Prawn will position your text by the left-most edge of its baseline, and
|
147
|
+
# flow along a single line. (This means that :align will not work)
|
148
|
+
#
|
149
|
+
# == Rotation
|
150
|
+
#
|
151
|
+
# Text can be rotated before it is placed on the canvas by specifying the
|
152
|
+
# <tt>:rotate</tt> option with a given angle. Rotation occurs counter-clockwise.
|
153
|
+
#
|
154
|
+
# == Encoding
|
155
|
+
#
|
156
|
+
# Note that strings passed to this function should be encoded as UTF-8.
|
157
|
+
# If you get unexpected characters appearing in your rendered document,
|
158
|
+
# check this.
|
159
|
+
#
|
160
|
+
# If the current font is a built-in one, although the string must be
|
161
|
+
# encoded as UTF-8, only characters that are available in WinAnsi
|
162
|
+
# are allowed.
|
163
|
+
#
|
164
|
+
# If an empty box is rendered to your PDF instead of the character you
|
165
|
+
# wanted it usually means the current font doesn't include that character.
|
166
|
+
#
|
167
|
+
# == Options (default values marked in [])
|
168
|
+
#
|
169
|
+
# <tt>:at</tt>:: <tt>[x, y]</tt>(required). The position at which to start the text
|
170
|
+
# <tt>:kerning</tt>:: <tt>boolean</tt>. Whether or not to use kerning (if it
|
171
|
+
# is available with the current font) [true]
|
172
|
+
# <tt>:size</tt>:: <tt>number</tt>. The font size to use. [current font
|
173
|
+
# size]
|
174
|
+
# <tt>:style</tt>:: The style to use. The requested style must be part of
|
175
|
+
# the current font familly. [current style]
|
176
|
+
#
|
177
|
+
# <tt>:rotate</tt>:: <tt>number</tt>. The angle to which to rotate text
|
178
|
+
#
|
179
|
+
# Raises <tt>ArgumentError</tt> if <tt>:at</tt> option omitted
|
180
|
+
# Raises <tt>ArgumentError</tt> if <tt>:align</tt> option included
|
181
|
+
#
|
182
|
+
def draw_text(text, options)
|
183
|
+
# we modify the options. don't change the user's hash
|
184
|
+
options = options.dup
|
185
|
+
inspect_options_for_draw_text(options)
|
186
|
+
# dup because normalize_encoding changes the string
|
187
|
+
text = text.to_s.dup
|
188
|
+
options = @text_options.merge(options)
|
189
|
+
save_font do
|
190
|
+
process_text_options(options)
|
191
|
+
font.normalize_encoding!(text) unless @skip_encoding
|
192
|
+
font_size(options[:size]) { draw_text!(text, options) }
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
private
|
197
|
+
|
198
|
+
def draw_remaining_text_on_new_pages(remaining_text, options)
|
199
|
+
while remaining_text.length > 0
|
200
|
+
@bounding_box.move_past_bottom
|
201
|
+
previous_remaining_text = remaining_text
|
202
|
+
remaining_text = fill_text_box(remaining_text, options)
|
203
|
+
break if remaining_text == previous_remaining_text
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def draw_indented_line(string, options)
|
208
|
+
indent(@indent_paragraphs) do
|
209
|
+
fill_text_box(string, options.dup.merge(:single_line => true))
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def fill_text_box(text, options)
|
214
|
+
bottom = @bounding_box.stretchy? ? @margin_box.absolute_bottom :
|
215
|
+
@bounding_box.absolute_bottom
|
216
|
+
|
217
|
+
options[:height] = y - bottom
|
218
|
+
options[:width] = bounds.width
|
219
|
+
options[:at] = [@bounding_box.left_side - @bounding_box.absolute_left,
|
220
|
+
y - @bounding_box.absolute_bottom]
|
221
|
+
|
222
|
+
box = Text::Box.new(text, options)
|
223
|
+
remaining_text = box.render
|
224
|
+
|
225
|
+
self.y -= box.height - box.descender
|
226
|
+
if @final_gap
|
227
|
+
self.y -= box.line_height + box.leading - box.ascender
|
228
|
+
end
|
229
|
+
remaining_text
|
230
|
+
end
|
231
|
+
|
232
|
+
def inspect_options_for_draw_text(options)
|
233
|
+
if options[:at].nil?
|
234
|
+
raise ArgumentError, "The :at option is required for draw_text"
|
235
|
+
elsif options[:align]
|
236
|
+
raise ArgumentError, "The :align option does not work with draw_text"
|
237
|
+
end
|
238
|
+
valid_options = VALID_TEXT_OPTIONS.dup.concat([:at, :rotate])
|
239
|
+
Prawn.verify_options(valid_options, options)
|
240
|
+
end
|
241
|
+
|
242
|
+
def inspect_options_for_text(options)
|
243
|
+
if options[:at]
|
244
|
+
raise ArgumentError, ":at is no longer a valid option with text." +
|
245
|
+
"use draw_text or text_box instead"
|
246
|
+
end
|
247
|
+
process_final_gap_option(options)
|
248
|
+
process_indent_paragraphs_option(options)
|
249
|
+
options[:document] = self
|
250
|
+
end
|
251
|
+
|
252
|
+
def process_final_gap_option(options)
|
253
|
+
@final_gap = options[:final_gap].nil? || options[:final_gap]
|
254
|
+
options.delete(:final_gap)
|
255
|
+
end
|
256
|
+
|
257
|
+
def process_indent_paragraphs_option(options)
|
258
|
+
@indent_paragraphs = options[:indent_paragraphs]
|
259
|
+
options.delete(:indent_paragraphs)
|
260
|
+
end
|
261
|
+
|
262
|
+
def move_text_position(dy)
|
263
|
+
bottom = @bounding_box.stretchy? ? @margin_box.absolute_bottom :
|
264
|
+
@bounding_box.absolute_bottom
|
265
|
+
|
266
|
+
@bounding_box.move_past_bottom if (y - dy) < bottom
|
267
|
+
|
268
|
+
self.y -= dy
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|