prawn-graph 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +51 -2
- data/Rakefile +16 -2
- data/lib/prawn/graph.rb +1 -4
- data/lib/prawn/graph/bar.rb +39 -143
- data/lib/prawn/graph/base.rb +207 -0
- data/lib/prawn/graph/errors.rb +2 -1
- data/lib/prawn/graph/grid.rb +5 -0
- data/lib/prawn/graph/line.rb +40 -1
- data/lib/prawn/graph/theme.rb +24 -0
- metadata +19 -312
- data/vendor/prawn-core/COPYING +0 -340
- data/vendor/prawn-core/HACKING +0 -46
- data/vendor/prawn-core/LICENSE +0 -56
- data/vendor/prawn-core/README +0 -138
- data/vendor/prawn-core/Rakefile +0 -75
- data/vendor/prawn-core/bench/afm_text_bench.rb +0 -18
- data/vendor/prawn-core/bench/png_type_6.rb +0 -15
- data/vendor/prawn-core/bench/ttf_text_bench.rb +0 -19
- data/vendor/prawn-core/bugs/indentation_across_pagebreaks.rb +0 -15
- data/vendor/prawn-core/bugs/resolved/canvas_sets_y_to_0.rb +0 -15
- data/vendor/prawn-core/bugs/resolved/png_barcode_issue.rb +0 -11
- data/vendor/prawn-core/bugs/resolved/transaction_page_number_issue_79.rb +0 -21
- data/vendor/prawn-core/bugs/resolved/ttf_fails_in_transactions.rb +0 -24
- data/vendor/prawn-core/data/encodings/win_ansi.txt +0 -29
- 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 +0 -342
- data/vendor/prawn-core/data/fonts/Courier-BoldOblique.afm +0 -342
- data/vendor/prawn-core/data/fonts/Courier-Oblique.afm +0 -342
- data/vendor/prawn-core/data/fonts/Courier.afm +0 -342
- 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 +0 -2827
- data/vendor/prawn-core/data/fonts/Helvetica-BoldOblique.afm +0 -2827
- data/vendor/prawn-core/data/fonts/Helvetica-Oblique.afm +0 -3051
- data/vendor/prawn-core/data/fonts/Helvetica.afm +0 -3051
- data/vendor/prawn-core/data/fonts/MustRead.html +0 -19
- data/vendor/prawn-core/data/fonts/Symbol.afm +0 -213
- data/vendor/prawn-core/data/fonts/Times-Bold.afm +0 -2588
- data/vendor/prawn-core/data/fonts/Times-BoldItalic.afm +0 -2384
- data/vendor/prawn-core/data/fonts/Times-Italic.afm +0 -2667
- data/vendor/prawn-core/data/fonts/Times-Roman.afm +0 -2419
- data/vendor/prawn-core/data/fonts/ZapfDingbats.afm +0 -225
- 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 +0 -1
- data/vendor/prawn-core/data/images/web-links.png +0 -0
- data/vendor/prawn-core/data/shift_jis_text.txt +0 -1
- data/vendor/prawn-core/examples/bounding_box/bounding_boxes.rb +0 -43
- data/vendor/prawn-core/examples/bounding_box/indentation.rb +0 -34
- data/vendor/prawn-core/examples/bounding_box/russian_boxes.rb +0 -36
- data/vendor/prawn-core/examples/bounding_box/stretched_nesting.rb +0 -67
- data/vendor/prawn-core/examples/column_box/column_box_example.rb +0 -43
- data/vendor/prawn-core/examples/example_helper.rb +0 -3
- data/vendor/prawn-core/examples/general/background.rb +0 -23
- data/vendor/prawn-core/examples/general/canvas.rb +0 -15
- data/vendor/prawn-core/examples/general/context_sensitive_headers.rb +0 -37
- data/vendor/prawn-core/examples/general/float.rb +0 -11
- data/vendor/prawn-core/examples/general/margin.rb +0 -36
- data/vendor/prawn-core/examples/general/measurement_units.rb +0 -51
- data/vendor/prawn-core/examples/general/metadata-info.rb +0 -16
- data/vendor/prawn-core/examples/general/multi_page_layout.rb +0 -18
- data/vendor/prawn-core/examples/general/outlines.rb +0 -50
- data/vendor/prawn-core/examples/general/page_geometry.rb +0 -31
- data/vendor/prawn-core/examples/general/page_numbering.rb +0 -15
- data/vendor/prawn-core/examples/general/repeaters.rb +0 -47
- data/vendor/prawn-core/examples/general/stamp.rb +0 -41
- data/vendor/prawn-core/examples/graphics/basic_images.rb +0 -23
- data/vendor/prawn-core/examples/graphics/cmyk.rb +0 -12
- data/vendor/prawn-core/examples/graphics/curves.rb +0 -11
- data/vendor/prawn-core/examples/graphics/hexagon.rb +0 -13
- data/vendor/prawn-core/examples/graphics/image_fit.rb +0 -15
- data/vendor/prawn-core/examples/graphics/image_flow.rb +0 -37
- data/vendor/prawn-core/examples/graphics/image_position.rb +0 -17
- data/vendor/prawn-core/examples/graphics/line.rb +0 -32
- data/vendor/prawn-core/examples/graphics/png_types.rb +0 -22
- data/vendor/prawn-core/examples/graphics/polygons.rb +0 -16
- data/vendor/prawn-core/examples/graphics/remote_images.rb +0 -12
- data/vendor/prawn-core/examples/graphics/rounded_polygons.rb +0 -19
- data/vendor/prawn-core/examples/graphics/rounded_rectangle.rb +0 -20
- data/vendor/prawn-core/examples/graphics/ruport_style_helpers.rb +0 -19
- data/vendor/prawn-core/examples/graphics/stroke_bounds.rb +0 -20
- data/vendor/prawn-core/examples/graphics/stroke_cap_and_join.rb +0 -45
- data/vendor/prawn-core/examples/graphics/stroke_dash.rb +0 -42
- data/vendor/prawn-core/examples/graphics/transformations.rb +0 -52
- data/vendor/prawn-core/examples/graphics/transparency.rb +0 -26
- data/vendor/prawn-core/examples/m17n/chinese_text_wrapping.rb +0 -17
- data/vendor/prawn-core/examples/m17n/euro.rb +0 -15
- data/vendor/prawn-core/examples/m17n/sjis.rb +0 -28
- data/vendor/prawn-core/examples/m17n/utf8.rb +0 -13
- data/vendor/prawn-core/examples/m17n/win_ansi_charset.rb +0 -54
- data/vendor/prawn-core/examples/text/alignment.rb +0 -18
- data/vendor/prawn-core/examples/text/dfont.rb +0 -48
- data/vendor/prawn-core/examples/text/family_based_styling.rb +0 -24
- data/vendor/prawn-core/examples/text/font_calculations.rb +0 -91
- data/vendor/prawn-core/examples/text/font_size.rb +0 -33
- data/vendor/prawn-core/examples/text/indent_paragraphs.rb +0 -18
- data/vendor/prawn-core/examples/text/kerning.rb +0 -30
- data/vendor/prawn-core/examples/text/rotated.rb +0 -98
- data/vendor/prawn-core/examples/text/simple_text.rb +0 -17
- data/vendor/prawn-core/examples/text/simple_text_ttf.rb +0 -17
- data/vendor/prawn-core/examples/text/span.rb +0 -29
- data/vendor/prawn-core/examples/text/text_box.rb +0 -88
- data/vendor/prawn-core/examples/text/text_box_returning_excess.rb +0 -51
- data/vendor/prawn-core/examples/text/text_flow.rb +0 -67
- data/vendor/prawn-core/lib/prawn/byte_string.rb +0 -7
- data/vendor/prawn-core/lib/prawn/compatibility.rb +0 -51
- data/vendor/prawn-core/lib/prawn/core.rb +0 -87
- data/vendor/prawn-core/lib/prawn/core/page.rb +0 -88
- data/vendor/prawn-core/lib/prawn/core/text.rb +0 -65
- data/vendor/prawn-core/lib/prawn/document.rb +0 -596
- data/vendor/prawn-core/lib/prawn/document/annotations.rb +0 -65
- data/vendor/prawn-core/lib/prawn/document/bounding_box.rb +0 -402
- data/vendor/prawn-core/lib/prawn/document/column_box.rb +0 -113
- data/vendor/prawn-core/lib/prawn/document/destinations.rb +0 -92
- data/vendor/prawn-core/lib/prawn/document/graphics_state.rb +0 -49
- data/vendor/prawn-core/lib/prawn/document/internals.rb +0 -153
- data/vendor/prawn-core/lib/prawn/document/page_geometry.rb +0 -136
- data/vendor/prawn-core/lib/prawn/document/snapshot.rb +0 -80
- data/vendor/prawn-core/lib/prawn/document/span.rb +0 -55
- data/vendor/prawn-core/lib/prawn/encoding.rb +0 -121
- data/vendor/prawn-core/lib/prawn/errors.rb +0 -83
- data/vendor/prawn-core/lib/prawn/font.rb +0 -329
- data/vendor/prawn-core/lib/prawn/font/afm.rb +0 -217
- data/vendor/prawn-core/lib/prawn/font/dfont.rb +0 -34
- data/vendor/prawn-core/lib/prawn/font/ttf.rb +0 -341
- data/vendor/prawn-core/lib/prawn/graphics.rb +0 -321
- data/vendor/prawn-core/lib/prawn/graphics/cap_style.rb +0 -38
- data/vendor/prawn-core/lib/prawn/graphics/color.rb +0 -205
- data/vendor/prawn-core/lib/prawn/graphics/dash.rb +0 -71
- data/vendor/prawn-core/lib/prawn/graphics/join_style.rb +0 -38
- data/vendor/prawn-core/lib/prawn/graphics/transformation.rb +0 -157
- data/vendor/prawn-core/lib/prawn/graphics/transparency.rb +0 -99
- data/vendor/prawn-core/lib/prawn/images.rb +0 -337
- data/vendor/prawn-core/lib/prawn/images/jpg.rb +0 -46
- data/vendor/prawn-core/lib/prawn/images/png.rb +0 -219
- data/vendor/prawn-core/lib/prawn/literal_string.rb +0 -14
- data/vendor/prawn-core/lib/prawn/measurement_extensions.rb +0 -46
- data/vendor/prawn-core/lib/prawn/measurements.rb +0 -71
- data/vendor/prawn-core/lib/prawn/name_tree.rb +0 -166
- data/vendor/prawn-core/lib/prawn/object_store.rb +0 -93
- data/vendor/prawn-core/lib/prawn/outline.rb +0 -278
- data/vendor/prawn-core/lib/prawn/pdf_object.rb +0 -83
- data/vendor/prawn-core/lib/prawn/reference.rb +0 -92
- data/vendor/prawn-core/lib/prawn/repeater.rb +0 -129
- data/vendor/prawn-core/lib/prawn/stamp.rb +0 -128
- data/vendor/prawn-core/lib/prawn/text.rb +0 -271
- data/vendor/prawn-core/lib/prawn/text/box.rb +0 -414
- data/vendor/prawn-core/meta/Rakefile +0 -36
- data/vendor/prawn-core/meta/lib/prawn.rb +0 -2
- data/vendor/prawn-core/reference_pdfs/alignment.pdf +0 -229
- 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 +0 -128
- data/vendor/prawn-core/reference_pdfs/canvas.pdf +0 -78
- 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 +0 -3671
- data/vendor/prawn-core/reference_pdfs/context_sensitive_headers.pdf +0 -2331
- data/vendor/prawn-core/reference_pdfs/curves.pdf +0 -62
- data/vendor/prawn-core/reference_pdfs/dfont.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/euro.pdf +0 -75
- data/vendor/prawn-core/reference_pdfs/family_style.pdf +0 -286
- data/vendor/prawn-core/reference_pdfs/flow.pdf +0 -964
- data/vendor/prawn-core/reference_pdfs/font_calculations.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/font_size.pdf +0 -142
- data/vendor/prawn-core/reference_pdfs/hexagon.pdf +0 -61
- 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 +0 -124
- data/vendor/prawn-core/reference_pdfs/kerning.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/landscape_a4.pdf +0 -52
- data/vendor/prawn-core/reference_pdfs/landscape_legal.pdf +0 -52
- data/vendor/prawn-core/reference_pdfs/landscape_letter.pdf +0 -52
- data/vendor/prawn-core/reference_pdfs/lines.pdf +0 -116
- data/vendor/prawn-core/reference_pdfs/margin.pdf +0 -3850
- data/vendor/prawn-core/reference_pdfs/measurement_units.pdf +0 -4667
- data/vendor/prawn-core/reference_pdfs/metadata-info.pdf +0 -88
- data/vendor/prawn-core/reference_pdfs/multi-layout.pdf +0 -209
- data/vendor/prawn-core/reference_pdfs/page_with_numbering.pdf +0 -156
- data/vendor/prawn-core/reference_pdfs/png_types.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/portrait_a4.pdf +0 -52
- data/vendor/prawn-core/reference_pdfs/portrait_legal.pdf +0 -52
- data/vendor/prawn-core/reference_pdfs/portrait_letter.pdf +0 -52
- data/vendor/prawn-core/reference_pdfs/pretty_polygons.pdf +0 -122
- data/vendor/prawn-core/reference_pdfs/remote_images.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/ruport.pdf +0 -101
- data/vendor/prawn-core/reference_pdfs/russian_boxes.pdf +0 -2780
- data/vendor/prawn-core/reference_pdfs/simple_text.pdf +0 -136
- 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 +0 -1975
- data/vendor/prawn-core/reference_pdfs/stamp.pdf +0 -649
- data/vendor/prawn-core/reference_pdfs/stretched_nesting.pdf +0 -200
- data/vendor/prawn-core/reference_pdfs/stroke_bounds.pdf +0 -135
- data/vendor/prawn-core/reference_pdfs/stroke_cap_and_join.pdf +0 -80
- data/vendor/prawn-core/reference_pdfs/stroke_dash.pdf +0 -457
- data/vendor/prawn-core/reference_pdfs/text_box.pdf +0 -962
- data/vendor/prawn-core/reference_pdfs/text_box_returning_excess.pdf +0 -271
- data/vendor/prawn-core/reference_pdfs/transparency.pdf +0 -347
- data/vendor/prawn-core/reference_pdfs/utf8.pdf +0 -0
- data/vendor/prawn-core/reference_pdfs/win-ansi.pdf +0 -6172
- data/vendor/prawn-core/spec/annotations_spec.rb +0 -90
- data/vendor/prawn-core/spec/bounding_box_spec.rb +0 -185
- data/vendor/prawn-core/spec/destinations_spec.rb +0 -15
- data/vendor/prawn-core/spec/document_spec.rb +0 -408
- data/vendor/prawn-core/spec/font_spec.rb +0 -314
- data/vendor/prawn-core/spec/graphics_spec.rb +0 -438
- data/vendor/prawn-core/spec/images_spec.rb +0 -79
- data/vendor/prawn-core/spec/jpg_spec.rb +0 -25
- data/vendor/prawn-core/spec/measurement_units_spec.rb +0 -23
- data/vendor/prawn-core/spec/name_tree_spec.rb +0 -112
- data/vendor/prawn-core/spec/object_store_spec.rb +0 -75
- data/vendor/prawn-core/spec/outline_spec.rb +0 -229
- data/vendor/prawn-core/spec/pdf_object_spec.rb +0 -122
- data/vendor/prawn-core/spec/png_spec.rb +0 -236
- data/vendor/prawn-core/spec/reference_spec.rb +0 -82
- data/vendor/prawn-core/spec/repeater_spec.rb +0 -96
- data/vendor/prawn-core/spec/snapshot_spec.rb +0 -138
- data/vendor/prawn-core/spec/span_spec.rb +0 -49
- data/vendor/prawn-core/spec/spec_helper.rb +0 -24
- data/vendor/prawn-core/spec/stamp_spec.rb +0 -108
- data/vendor/prawn-core/spec/stroke_styles_spec.rb +0 -152
- data/vendor/prawn-core/spec/text_at_spec.rb +0 -119
- data/vendor/prawn-core/spec/text_box_spec.rb +0 -603
- data/vendor/prawn-core/spec/text_spec.rb +0 -308
- data/vendor/prawn-core/spec/transparency_spec.rb +0 -75
- data/vendor/prawn-core/vendor/pdf-inspector/README +0 -18
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector.rb +0 -26
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/extgstate.rb +0 -18
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/graphics.rb +0 -131
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/page.rb +0 -25
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/text.rb +0 -31
- data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/xobject.rb +0 -19
- 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 +0 -45
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk.rb +0 -102
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/directory.rb +0 -17
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/encoding/mac_roman.rb +0 -88
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/encoding/windows_1252.rb +0 -69
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/reader.rb +0 -44
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/resource_file.rb +0 -78
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset.rb +0 -18
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/base.rb +0 -141
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb +0 -46
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/unicode.rb +0 -48
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/unicode_8bit.rb +0 -63
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/windows_1252.rb +0 -51
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset_collection.rb +0 -72
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table.rb +0 -46
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap.rb +0 -34
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/format00.rb +0 -54
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/format04.rb +0 -126
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/subtable.rb +0 -79
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf.rb +0 -64
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf/compound.rb +0 -81
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf/simple.rb +0 -37
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/head.rb +0 -44
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/hhea.rb +0 -41
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/hmtx.rb +0 -47
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/kern.rb +0 -79
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/kern/format0.rb +0 -62
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/loca.rb +0 -43
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/maxp.rb +0 -40
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/name.rb +0 -119
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/os2.rb +0 -78
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post.rb +0 -91
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format10.rb +0 -43
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format20.rb +0 -35
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format25.rb +0 -23
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format30.rb +0 -17
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format40.rb +0 -17
- data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/simple.rb +0 -14
- data/vendor/prawn-core/www/index.html +0 -196
- data/vendor/prawn-core/www/media/bounding_boxes.pdf +0 -146
- 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 +0 -350
- 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 +0 -113
- data/vendor/prawn-core/www/prawn.css +0 -86
- data/vendor/prawn-core/www/twilight.css +0 -266
@@ -1,92 +0,0 @@
|
|
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
|
@@ -1,129 +0,0 @@
|
|
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
|
-
|
@@ -1,128 +0,0 @@
|
|
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
|
@@ -1,271 +0,0 @@
|
|
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
|