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,90 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
+
|
5
|
+
class PageAnnotations
|
6
|
+
attr_reader :pages
|
7
|
+
|
8
|
+
def self.parse(document)
|
9
|
+
receiver = new
|
10
|
+
PDF::Reader.string(document.render, receiver)
|
11
|
+
return receiver
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@pages = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def begin_page(params)
|
19
|
+
@pages << params
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "When creating annotations" do
|
24
|
+
|
25
|
+
before(:each) { create_pdf }
|
26
|
+
|
27
|
+
it "should append annotation to current page" do
|
28
|
+
@pdf.start_new_page
|
29
|
+
@pdf.annotate(:Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
|
30
|
+
obj = PageAnnotations.parse(@pdf)
|
31
|
+
obj.pages[0][:Annots].nil?.should == true
|
32
|
+
obj.pages[1][:Annots].length.should == 1
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should force :Type to be :Annot" do
|
36
|
+
opts = @pdf.annotate(:Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
|
37
|
+
opts[:Type].should == :Annot
|
38
|
+
opts = @pdf.annotate(:Type => :Bogus, :Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
|
39
|
+
opts[:Type].should == :Annot
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "When creating text annotations" do
|
45
|
+
|
46
|
+
before(:each) do
|
47
|
+
@rect = [0,0,10,10]
|
48
|
+
@content = "Hello, world!"
|
49
|
+
create_pdf
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should build appropriate annotation" do
|
53
|
+
opts = @pdf.text_annotation(@rect, @content)
|
54
|
+
opts[:Type].should == :Annot
|
55
|
+
opts[:Subtype].should == :Text
|
56
|
+
opts[:Rect].should == @rect
|
57
|
+
opts[:Contents].should == @content
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should merge extra options" do
|
61
|
+
opts = @pdf.text_annotation(@rect, @content, :Open => true, :Subtype => :Bogus)
|
62
|
+
opts[:Subtype].should == :Text
|
63
|
+
opts[:Open].should == true
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "When creating link annotations" do
|
69
|
+
|
70
|
+
before(:each) do
|
71
|
+
@rect = [0,0,10,10]
|
72
|
+
@dest = "home"
|
73
|
+
create_pdf
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should build appropriate annotation" do
|
77
|
+
opts = @pdf.link_annotation(@rect, :Dest => @dest)
|
78
|
+
opts[:Type].should == :Annot
|
79
|
+
opts[:Subtype].should == :Link
|
80
|
+
opts[:Rect].should == @rect
|
81
|
+
opts[:Dest].should == @dest
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should merge extra options" do
|
85
|
+
opts = @pdf.link_annotation(@rect, :Dest => @dest, :Subtype => :Bogus)
|
86
|
+
opts[:Subtype].should == :Link
|
87
|
+
opts[:Dest].should == @dest
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
+
|
5
|
+
describe "A bounding box" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@x = 100
|
9
|
+
@y = 125
|
10
|
+
@width = 50
|
11
|
+
@height = 75
|
12
|
+
@box = Prawn::Document::BoundingBox.new(nil, [@x,@y], :width => @width,
|
13
|
+
:height => @height )
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have an anchor at (x, y - height)" do
|
17
|
+
@box.anchor.should == [@x,@y-@height]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have a left boundary of 0" do
|
21
|
+
@box.left.should == 0
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have a right boundary equal to the width" do
|
25
|
+
@box.right.should == @width
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a top boundary of height" do
|
29
|
+
@box.top.should == @height
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have a bottom boundary of 0" do
|
33
|
+
@box.bottom.should == 0
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have a top-left of [0,height]" do
|
37
|
+
@box.top_left.should == [0,@height]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a top-right of [width,height]" do
|
41
|
+
@box.top_right.should == [@width,@height]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should have a bottom-left of [0,0]" do
|
45
|
+
@box.bottom_left.should == [0,0]
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have a bottom-right of [width,0]" do
|
49
|
+
@box.bottom_right.should == [@width,0]
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have an absolute left boundary of x" do
|
53
|
+
@box.absolute_left.should == @x
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should have an absolute right boundary of x + width" do
|
57
|
+
@box.absolute_right.should == @x + @width
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have an absolute top boundary of y" do
|
61
|
+
@box.absolute_top.should == @y
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have an absolute bottom boundary of y - height" do
|
65
|
+
@box.absolute_bottom.should == @y - @height
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should have an absolute bottom-left of [x,y-height]" do
|
69
|
+
@box.absolute_bottom_left.should == [@x, @y - @height]
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have an absolute bottom-right of [x+width,y-height]" do
|
73
|
+
@box.absolute_bottom_right.should == [@x + @width , @y - @height]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should have an absolute top-left of [x,y]" do
|
77
|
+
@box.absolute_top_left.should == [@x, @y]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have an absolute top-right of [x+width,y]" do
|
81
|
+
@box.absolute_top_right.should == [@x + @width, @y]
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "drawing bounding boxes" do
|
88
|
+
|
89
|
+
before(:each) { create_pdf }
|
90
|
+
|
91
|
+
it "should restore the margin box when bounding box exits" do
|
92
|
+
margin_box = @pdf.bounds
|
93
|
+
|
94
|
+
@pdf.bounding_box [100,500] do
|
95
|
+
#nothing
|
96
|
+
end
|
97
|
+
|
98
|
+
@pdf.bounds.should == margin_box
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should restore the parent bounding box when calls are nested" do
|
103
|
+
@pdf.bounding_box [100,500], :width => 300, :height => 300 do
|
104
|
+
|
105
|
+
@pdf.bounds.absolute_top.should == 500 + @pdf.margin_box.absolute_bottom
|
106
|
+
@pdf.bounds.absolute_left.should == 100 + @pdf.margin_box.absolute_left
|
107
|
+
|
108
|
+
parent_box = @pdf.bounds
|
109
|
+
|
110
|
+
@pdf.bounding_box [50,200], :width => 100, :height => 100 do
|
111
|
+
@pdf.bounds.absolute_top.should == 200 + parent_box.absolute_bottom
|
112
|
+
@pdf.bounds.absolute_left.should == 50 + parent_box.absolute_left
|
113
|
+
end
|
114
|
+
|
115
|
+
@pdf.bounds.absolute_top.should == 500 + @pdf.margin_box.absolute_bottom
|
116
|
+
@pdf.bounds.absolute_left.should == 100 + @pdf.margin_box.absolute_left
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should calculate a height if none is specified" do
|
122
|
+
@pdf.bounding_box([100, 500], :width => 100) do
|
123
|
+
@pdf.text "The rain in Spain falls mainly on the plains."
|
124
|
+
end
|
125
|
+
|
126
|
+
@pdf.y.should.be.close 458.384, 0.001
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should keep track of the max height the box was stretched to" do
|
130
|
+
box = @pdf.bounding_box(@pdf.bounds.top_left, :width => 100) do
|
131
|
+
@pdf.move_down 100
|
132
|
+
@pdf.move_up 15
|
133
|
+
end
|
134
|
+
|
135
|
+
assert_equal 100, box.height
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "Indentation" do
|
141
|
+
before(:each) { create_pdf }
|
142
|
+
|
143
|
+
it "should temporarily shift the x coordinate and width" do
|
144
|
+
@pdf.bounding_box([100,100], :width => 200) do
|
145
|
+
@pdf.indent(20) do
|
146
|
+
@pdf.bounds.absolute_left.should == 120
|
147
|
+
@pdf.bounds.width.should == 180
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should restore the x coordinate and width after block exits" do
|
153
|
+
@pdf.bounding_box([100,100], :width => 200) do
|
154
|
+
@pdf.indent(20) do
|
155
|
+
# no-op
|
156
|
+
end
|
157
|
+
@pdf.bounds.absolute_left.should == 100
|
158
|
+
@pdf.bounds.width.should == 200
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should restore the x coordinate and width on error" do
|
163
|
+
@pdf.bounding_box([100,100], :width => 200) do
|
164
|
+
begin
|
165
|
+
@pdf.indent(20) { raise }
|
166
|
+
rescue
|
167
|
+
@pdf.bounds.absolute_left.should == 100
|
168
|
+
@pdf.bounds.width.should == 200
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "A canvas" do
|
176
|
+
before(:each) { create_pdf }
|
177
|
+
|
178
|
+
it "should use whatever the last set y position is" do
|
179
|
+
@pdf.canvas do
|
180
|
+
@pdf.bounding_box([100,500],:width => 200) { @pdf.move_down 50 }
|
181
|
+
end
|
182
|
+
@pdf.y.should == 450
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
+
|
5
|
+
describe "When creating destinations" do
|
6
|
+
|
7
|
+
before(:each) { create_pdf }
|
8
|
+
|
9
|
+
it "should add entry to Dests name tree" do
|
10
|
+
@pdf.dests.data.empty?.should == true
|
11
|
+
@pdf.add_dest "candy", "chocolate"
|
12
|
+
@pdf.dests.data.size.should == 1
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,408 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "tempfile"
|
3
|
+
|
4
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
5
|
+
|
6
|
+
describe "The cursor" do
|
7
|
+
it "should equal pdf.y - bounds.absolute_bottom" do
|
8
|
+
pdf = Prawn::Document.new
|
9
|
+
pdf.cursor.should == pdf.bounds.top
|
10
|
+
|
11
|
+
pdf.y = 300
|
12
|
+
pdf.cursor.should == pdf.y - pdf.bounds.absolute_bottom
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to move relative to the bottom margin" do
|
16
|
+
pdf = Prawn::Document.new
|
17
|
+
pdf.move_cursor_to(10)
|
18
|
+
|
19
|
+
pdf.cursor.should == 10
|
20
|
+
pdf.y.should == pdf.cursor + pdf.bounds.absolute_bottom
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "when generating a document from a subclass" do
|
25
|
+
it "should be an instance of the subclass" do
|
26
|
+
custom_document = Class.new(Prawn::Document)
|
27
|
+
custom_document.generate(Tempfile.new("generate_test").path) do |e|
|
28
|
+
e.class.should == custom_document
|
29
|
+
e.should.be.kind_of(Prawn::Document)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should retain any extensions found on Prawn::Document" do
|
34
|
+
mod1 = Module.new { attr_reader :test_extensions1 }
|
35
|
+
mod2 = Module.new { attr_reader :test_extensions2 }
|
36
|
+
|
37
|
+
Prawn::Document.extensions << mod1 << mod2
|
38
|
+
|
39
|
+
custom_document = Class.new(Prawn::Document)
|
40
|
+
assert_equal [mod1, mod2], custom_document.extensions
|
41
|
+
|
42
|
+
# remove the extensions we added to prawn document
|
43
|
+
Prawn::Document.extensions.delete(mod1)
|
44
|
+
Prawn::Document.extensions.delete(mod2)
|
45
|
+
|
46
|
+
assert ! Prawn::Document.new.respond_to?(:test_extensions1)
|
47
|
+
assert ! Prawn::Document.new.respond_to?(:test_extensions2)
|
48
|
+
|
49
|
+
# verify these still exist on custom class
|
50
|
+
assert_equal [mod1, mod2], custom_document.extensions
|
51
|
+
|
52
|
+
assert custom_document.new.respond_to?(:test_extensions1)
|
53
|
+
assert custom_document.new.respond_to?(:test_extensions2)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
describe "When creating multi-page documents" do
|
60
|
+
|
61
|
+
before(:each) { create_pdf }
|
62
|
+
|
63
|
+
it "should initialize with a single page" do
|
64
|
+
page_counter = PDF::Inspector::Page.analyze(@pdf.render)
|
65
|
+
|
66
|
+
page_counter.pages.size.should == 1
|
67
|
+
@pdf.page_count.should == 1
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should provide an accurate page_count" do
|
71
|
+
3.times { @pdf.start_new_page }
|
72
|
+
page_counter = PDF::Inspector::Page.analyze(@pdf.render)
|
73
|
+
|
74
|
+
page_counter.pages.size.should == 4
|
75
|
+
@pdf.page_count.should == 4
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "When beginning each new page" do
|
81
|
+
|
82
|
+
describe "Background template feature" do
|
83
|
+
before(:each) do
|
84
|
+
@filename = "#{Prawn::BASEDIR}/data/images/pigs.jpg"
|
85
|
+
@pdf = Prawn::Document.new(:background => @filename)
|
86
|
+
end
|
87
|
+
it "should place a background image if it is in options block" do
|
88
|
+
output = @pdf.render
|
89
|
+
images = PDF::Inspector::XObject.analyze(output)
|
90
|
+
# there should be 2 images in the page resources
|
91
|
+
images.page_xobjects.first.size.should == 1
|
92
|
+
end
|
93
|
+
it "should place a background image if it is in options block" do
|
94
|
+
@pdf.instance_variable_defined?(:@background).should == true
|
95
|
+
@pdf.instance_variable_get(:@background).should == @filename
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "The page_number method" do
|
105
|
+
it "should be 1 for a new document" do
|
106
|
+
pdf = Prawn::Document.new
|
107
|
+
pdf.page_number.should == 1
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should be 0 for documents with no pages" do
|
111
|
+
pdf = Prawn::Document.new(:skip_page_creation => true)
|
112
|
+
pdf.page_number.should == 0
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should be changed by go_to_page" do
|
116
|
+
pdf = Prawn::Document.new
|
117
|
+
10.times { pdf.start_new_page }
|
118
|
+
pdf.go_to_page 3
|
119
|
+
pdf.page_number.should == 3
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "on_page_create callback" do
|
125
|
+
before do
|
126
|
+
create_pdf
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should be invoked with document" do
|
130
|
+
called_with = nil
|
131
|
+
|
132
|
+
@pdf.on_page_create { |*args| called_with = args }
|
133
|
+
|
134
|
+
@pdf.start_new_page
|
135
|
+
|
136
|
+
called_with.should == [@pdf]
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should be invoked for each new page" do
|
140
|
+
trigger = mock()
|
141
|
+
trigger.expects(:fire).times(5)
|
142
|
+
|
143
|
+
@pdf.on_page_create { trigger.fire }
|
144
|
+
|
145
|
+
5.times { @pdf.start_new_page }
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should be replaceable" do
|
149
|
+
trigger1 = mock()
|
150
|
+
trigger1.expects(:fire).times(1)
|
151
|
+
|
152
|
+
trigger2 = mock()
|
153
|
+
trigger2.expects(:fire).times(1)
|
154
|
+
|
155
|
+
@pdf.on_page_create { trigger1.fire }
|
156
|
+
|
157
|
+
@pdf.start_new_page
|
158
|
+
|
159
|
+
@pdf.on_page_create { trigger2.fire }
|
160
|
+
|
161
|
+
@pdf.start_new_page
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should be clearable by calling on_page_create without a block" do
|
165
|
+
trigger = mock()
|
166
|
+
trigger.expects(:fire).times(1)
|
167
|
+
|
168
|
+
@pdf.on_page_create { trigger.fire }
|
169
|
+
|
170
|
+
@pdf.start_new_page
|
171
|
+
|
172
|
+
@pdf.on_page_create
|
173
|
+
|
174
|
+
@pdf.start_new_page
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "Document compression" do
|
180
|
+
|
181
|
+
it "should not compress the page content stream if compression is disabled" do
|
182
|
+
|
183
|
+
pdf = Prawn::Document.new(:compress => false)
|
184
|
+
pdf.page.content.stubs(:compress_stream).returns(true)
|
185
|
+
pdf.page.content.expects(:compress_stream).never
|
186
|
+
|
187
|
+
pdf.text "Hi There" * 20
|
188
|
+
pdf.render
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should compress the page content stream if compression is enabled" do
|
192
|
+
|
193
|
+
pdf = Prawn::Document.new(:compress => true)
|
194
|
+
pdf.page.content.stubs(:compress_stream).returns(true)
|
195
|
+
pdf.page.content.expects(:compress_stream).once
|
196
|
+
|
197
|
+
pdf.text "Hi There" * 20
|
198
|
+
pdf.render
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should result in a smaller file size when compressed" do
|
202
|
+
doc_uncompressed = Prawn::Document.new
|
203
|
+
doc_compressed = Prawn::Document.new(:compress => true)
|
204
|
+
[doc_compressed, doc_uncompressed].each do |pdf|
|
205
|
+
pdf.font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
|
206
|
+
pdf.text "更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历" * 10
|
207
|
+
end
|
208
|
+
|
209
|
+
doc_compressed.render.length.should.be < doc_uncompressed.render.length
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "When reopening pages" do
|
215
|
+
it "should modify the content stream size" do
|
216
|
+
@pdf = Prawn::Document.new do |pdf|
|
217
|
+
pdf.text "Page 1"
|
218
|
+
pdf.start_new_page
|
219
|
+
pdf.text "Page 2"
|
220
|
+
pdf.go_to_page 0
|
221
|
+
pdf.text "More for page 1"
|
222
|
+
end
|
223
|
+
|
224
|
+
# MalformedPDFError raised if content stream actual length does not match
|
225
|
+
# dictionary length
|
226
|
+
lambda{ PDF::Inspector::Page.analyze(@pdf.render) }.
|
227
|
+
should.not.raise(PDF::Reader::MalformedPDFError)
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should insert pages after the current page when calling start_new_page" do
|
231
|
+
pdf = Prawn::Document.new
|
232
|
+
3.times { |i| pdf.text "Old page #{i+1}"; pdf.start_new_page }
|
233
|
+
pdf.go_to_page 1
|
234
|
+
pdf.start_new_page
|
235
|
+
pdf.text "New page 2"
|
236
|
+
|
237
|
+
pdf.page_number.should == 2
|
238
|
+
|
239
|
+
pages = PDF::Inspector::Page.analyze(pdf.render).pages
|
240
|
+
pages.size.should == 5
|
241
|
+
pages[1][:strings].should == ["New page 2"]
|
242
|
+
pages[2][:strings].should == ["Old page 2"]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe "When setting page size" do
|
247
|
+
it "should default to LETTER" do
|
248
|
+
@pdf = Prawn::Document.new
|
249
|
+
pages = PDF::Inspector::Page.analyze(@pdf.render).pages
|
250
|
+
pages.first[:size].should == Prawn::Document::PageGeometry::SIZES["LETTER"]
|
251
|
+
end
|
252
|
+
|
253
|
+
(Prawn::Document::PageGeometry::SIZES.keys - ["LETTER"]).each do |k|
|
254
|
+
it "should provide #{k} geometry" do
|
255
|
+
@pdf = Prawn::Document.new(:page_size => k)
|
256
|
+
pages = PDF::Inspector::Page.analyze(@pdf.render).pages
|
257
|
+
pages.first[:size].should == Prawn::Document::PageGeometry::SIZES[k]
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should allow custom page size" do
|
262
|
+
@pdf = Prawn::Document.new(:page_size => [1920, 1080] )
|
263
|
+
pages = PDF::Inspector::Page.analyze(@pdf.render).pages
|
264
|
+
pages.first[:size].should == [1920, 1080]
|
265
|
+
end
|
266
|
+
|
267
|
+
end
|
268
|
+
|
269
|
+
describe "When setting page layout" do
|
270
|
+
it "should reverse coordinates for landscape" do
|
271
|
+
@pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
|
272
|
+
pages = PDF::Inspector::Page.analyze(@pdf.render).pages
|
273
|
+
pages.first[:size].should == Prawn::Document::PageGeometry::SIZES["A4"].reverse
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "The mask() feature" do
|
278
|
+
it "should allow transactional restoration of attributes" do
|
279
|
+
@pdf = Prawn::Document.new
|
280
|
+
y, line_width = @pdf.y, @pdf.line_width
|
281
|
+
@pdf.mask(:y, :line_width) do
|
282
|
+
@pdf.y = y + 1
|
283
|
+
@pdf.line_width = line_width + 1
|
284
|
+
@pdf.y.should.not == y
|
285
|
+
@pdf.line_width.should.not == line_width
|
286
|
+
end
|
287
|
+
@pdf.y.should == y
|
288
|
+
@pdf.line_width.should == line_width
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe "The group() feature" do
|
293
|
+
it "should group a simple block on a single page" do
|
294
|
+
pdf = Prawn::Document.new do
|
295
|
+
self.y = 50
|
296
|
+
group do
|
297
|
+
text "Hello"
|
298
|
+
text "World"
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
pages = PDF::Inspector::Page.analyze(pdf.render).pages
|
303
|
+
pages.size.should == 2
|
304
|
+
pages[0][:strings].should == []
|
305
|
+
pages[1][:strings].should == ["Hello", "World"]
|
306
|
+
end
|
307
|
+
|
308
|
+
it "should raise CannotGroup if the content is too tall" do
|
309
|
+
lambda {
|
310
|
+
Prawn::Document.new do
|
311
|
+
group do
|
312
|
+
100.times { text "Too long" }
|
313
|
+
end
|
314
|
+
end.render
|
315
|
+
}.should.raise(Prawn::Errors::CannotGroup)
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should group within individual column boxes" do
|
319
|
+
pdf = Prawn::Document.new do
|
320
|
+
# Set up columns with grouped blocks of 0..49. 0 to 49 is slightly short
|
321
|
+
# of the height of one page / column, so each column should get its own
|
322
|
+
# group (every column should start with zero).
|
323
|
+
column_box([0, bounds.top], :width => bounds.width, :columns => 7) do
|
324
|
+
10.times do
|
325
|
+
group { 50.times { |i| text(i.to_s) } }
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
# Second page should start with a 0 because it's a new group.
|
331
|
+
pages = PDF::Inspector::Page.analyze(pdf.render).pages
|
332
|
+
pages.size.should == 2
|
333
|
+
pages[1][:strings].first.should == '0'
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe "The render() feature" do
|
338
|
+
if "spec".respond_to?(:encode!)
|
339
|
+
it "should return a 8 bit encoded string on a m17n aware VM" do
|
340
|
+
@pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
|
341
|
+
@pdf.line [100,100], [200,200]
|
342
|
+
str = @pdf.render
|
343
|
+
str.encoding.to_s.should == "ASCII-8BIT"
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
it "should trigger before_render callbacks just before rendering" do
|
348
|
+
pdf = Prawn::Document.new
|
349
|
+
|
350
|
+
seq = sequence("callback_order")
|
351
|
+
|
352
|
+
# Verify the order: finalize -> fire callbacks -> render body
|
353
|
+
pdf.expects(:finalize_all_page_contents).in_sequence(seq)
|
354
|
+
trigger = mock()
|
355
|
+
trigger.expects(:fire).in_sequence(seq)
|
356
|
+
|
357
|
+
# Store away the render_body method to be called below
|
358
|
+
render_body = pdf.method(:render_body)
|
359
|
+
pdf.expects(:render_body).in_sequence(seq)
|
360
|
+
|
361
|
+
pdf.before_render{ trigger.fire }
|
362
|
+
|
363
|
+
# Render the body to set up object offsets
|
364
|
+
render_body.call(StringIO.new)
|
365
|
+
pdf.render
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe "The :optimize_objects option" do
|
370
|
+
before(:all) do
|
371
|
+
@wasteful_doc = lambda do
|
372
|
+
transaction { start_new_page; text "Hidden text"; rollback }
|
373
|
+
text "Hello world"
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
it "should result in fewer objects when enabled" do
|
378
|
+
wasteful_pdf = Prawn::Document.new(&@wasteful_doc)
|
379
|
+
frugal_pdf = Prawn::Document.new(:optimize_objects => true,
|
380
|
+
&@wasteful_doc)
|
381
|
+
frugal_pdf.render.size.should.be < wasteful_pdf.render.size
|
382
|
+
end
|
383
|
+
|
384
|
+
it "should default to :false" do
|
385
|
+
default_pdf = Prawn::Document.new(&@wasteful_doc)
|
386
|
+
wasteful_pdf = Prawn::Document.new(:optimize_objects => false,
|
387
|
+
&@wasteful_doc)
|
388
|
+
default_pdf.render.size.should == wasteful_pdf.render.size
|
389
|
+
end
|
390
|
+
|
391
|
+
end
|
392
|
+
|
393
|
+
describe "PDF file versions" do
|
394
|
+
it "should default to 1.3" do
|
395
|
+
@pdf = Prawn::Document.new
|
396
|
+
str = @pdf.render
|
397
|
+
str[0,8].should == "%PDF-1.3"
|
398
|
+
end
|
399
|
+
|
400
|
+
it "should allow the default to be changed" do
|
401
|
+
@pdf = Prawn::Document.new
|
402
|
+
@pdf.__send__(:min_version, 1.4)
|
403
|
+
str = @pdf.render
|
404
|
+
str[0,8].should == "%PDF-1.4"
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
|