prawn 0.15.0 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +2 -2
- data/LICENSE +1 -1
- data/README.md +96 -0
- data/Rakefile +27 -30
- data/data/fonts/Action Man.dfont +0 -0
- data/data/fonts/Activa.ttf +0 -0
- data/data/fonts/Chalkboard.ttf +0 -0
- data/data/fonts/DejaVuSans.ttf +0 -0
- data/data/fonts/Dustismo_Roman.ttf +0 -0
- data/data/fonts/comicsans.ttf +0 -0
- data/data/fonts/gkai00mp.ttf +0 -0
- data/data/images/16bit.alpha +0 -0
- data/data/images/16bit.dat +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.dat +0 -0
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.dat +0 -0
- data/data/images/rails.dat +0 -0
- data/data/images/rails.png +0 -0
- data/data/pdfs/nested_pages.pdf +13 -13
- data/lib/prawn.rb +21 -85
- data/lib/prawn/compatibility.rb +51 -0
- data/lib/prawn/core.rb +85 -0
- data/lib/prawn/core/annotations.rb +61 -0
- data/lib/prawn/core/byte_string.rb +9 -0
- data/lib/prawn/core/destinations.rb +90 -0
- data/lib/prawn/core/document_state.rb +78 -0
- data/lib/prawn/core/literal_string.rb +16 -0
- data/lib/prawn/core/name_tree.rb +177 -0
- data/lib/prawn/core/object_store.rb +264 -0
- data/lib/prawn/core/page.rb +215 -0
- data/lib/prawn/core/pdf_object.rb +108 -0
- data/lib/prawn/core/reference.rb +115 -0
- data/lib/prawn/core/text.rb +268 -0
- data/lib/prawn/core/text/formatted/arranger.rb +294 -0
- data/lib/prawn/core/text/formatted/line_wrap.rb +273 -0
- data/lib/prawn/core/text/formatted/wrap.rb +153 -0
- data/lib/prawn/document.rb +122 -155
- data/lib/prawn/document/bounding_box.rb +7 -36
- data/lib/prawn/document/column_box.rb +10 -38
- data/lib/prawn/document/graphics_state.rb +74 -11
- data/lib/prawn/document/internals.rb +23 -24
- data/lib/prawn/document/page_geometry.rb +136 -0
- data/lib/prawn/document/snapshot.rb +6 -7
- data/lib/prawn/document/span.rb +10 -12
- data/lib/prawn/encoding.rb +10 -9
- data/lib/prawn/errors.rb +30 -15
- data/lib/prawn/font.rb +104 -136
- data/lib/prawn/font/afm.rb +44 -46
- data/lib/prawn/font/dfont.rb +3 -4
- data/lib/prawn/font/ttf.rb +50 -31
- data/lib/prawn/graphics.rb +57 -302
- data/lib/prawn/graphics/cap_style.rb +3 -4
- data/lib/prawn/graphics/color.rb +5 -13
- data/lib/prawn/graphics/dash.rb +31 -53
- data/lib/prawn/graphics/gradient.rb +84 -0
- data/lib/prawn/graphics/join_style.rb +7 -9
- data/lib/prawn/graphics/transformation.rb +9 -10
- data/lib/prawn/graphics/transparency.rb +1 -3
- data/lib/prawn/images.rb +59 -69
- data/lib/prawn/images/image.rb +22 -6
- data/lib/prawn/images/jpg.rb +14 -20
- data/lib/prawn/images/png.rb +118 -61
- data/lib/prawn/layout.rb +15 -10
- data/lib/prawn/layout/grid.rb +54 -66
- data/lib/prawn/measurement_extensions.rb +6 -10
- data/lib/prawn/measurements.rb +21 -27
- data/lib/prawn/outline.rb +308 -6
- data/lib/prawn/repeater.rb +8 -10
- data/lib/prawn/security.rb +33 -55
- data/lib/prawn/security/arcfour.rb +0 -1
- data/lib/prawn/stamp.rb +3 -5
- data/lib/prawn/table.rb +60 -188
- data/lib/prawn/table/cell.rb +44 -272
- data/lib/prawn/table/cell/image.rb +3 -2
- data/lib/prawn/table/cell/in_table.rb +2 -4
- data/lib/prawn/table/cell/subtable.rb +2 -2
- data/lib/prawn/table/cell/text.rb +18 -41
- data/lib/prawn/table/cells.rb +48 -142
- data/lib/prawn/text.rb +25 -32
- data/lib/prawn/text/box.rb +6 -12
- data/lib/prawn/text/formatted.rb +4 -5
- data/lib/prawn/text/formatted/box.rb +59 -96
- data/lib/prawn/text/formatted/fragment.rb +23 -34
- data/lib/prawn/text/formatted/parser.rb +5 -15
- data/prawn.gemspec +13 -24
- data/spec/annotations_spec.rb +32 -16
- data/spec/bounding_box_spec.rb +17 -119
- data/spec/cell_spec.rb +42 -112
- data/spec/destinations_spec.rb +5 -5
- data/spec/document_spec.rb +111 -155
- data/spec/extensions/mocha.rb +0 -1
- data/spec/font_spec.rb +99 -149
- data/spec/formatted_text_arranger_spec.rb +43 -43
- data/spec/formatted_text_box_spec.rb +44 -43
- data/spec/formatted_text_fragment_spec.rb +8 -8
- data/spec/graphics_spec.rb +68 -151
- data/spec/grid_spec.rb +15 -26
- data/spec/images_spec.rb +30 -51
- data/spec/inline_formatted_text_parser_spec.rb +20 -69
- data/spec/jpg_spec.rb +4 -4
- data/spec/line_wrap_spec.rb +28 -28
- data/spec/measurement_units_spec.rb +6 -6
- data/spec/name_tree_spec.rb +112 -0
- data/spec/object_store_spec.rb +106 -17
- data/spec/outline_spec.rb +63 -103
- data/spec/pdf_object_spec.rb +170 -0
- data/spec/png_spec.rb +25 -25
- data/spec/reference_spec.rb +65 -8
- data/spec/repeater_spec.rb +10 -10
- data/spec/security_spec.rb +12 -44
- data/spec/snapshot_spec.rb +7 -7
- data/spec/span_spec.rb +15 -10
- data/spec/spec_helper.rb +8 -32
- data/spec/stamp_spec.rb +30 -29
- data/spec/stroke_styles_spec.rb +18 -36
- data/spec/table_spec.rb +111 -706
- data/spec/template_spec.rb +297 -0
- data/spec/text_at_spec.rb +33 -19
- data/spec/text_box_spec.rb +64 -100
- data/spec/text_rendering_mode_spec.rb +5 -5
- data/spec/text_spacing_spec.rb +4 -4
- data/spec/text_spec.rb +64 -84
- data/spec/transparency_spec.rb +5 -5
- metadata +290 -463
- checksums.yaml +0 -7
- data/.yardopts +0 -10
- data/Gemfile +0 -11
- data/data/images/16bit.color +0 -0
- data/data/images/dice.color +0 -0
- data/data/images/indexed_color.dat +0 -0
- data/data/images/indexed_color.png +0 -0
- data/data/images/page_white_text.color +0 -0
- data/lib/prawn/font_metric_cache.rb +0 -47
- data/lib/prawn/graphics/patterns.rb +0 -138
- data/lib/prawn/image_handler.rb +0 -36
- data/lib/prawn/soft_mask.rb +0 -96
- data/lib/prawn/table/cell/span_dummy.rb +0 -93
- data/lib/prawn/table/column_width_calculator.rb +0 -61
- data/lib/prawn/text/formatted/arranger.rb +0 -290
- data/lib/prawn/text/formatted/line_wrap.rb +0 -266
- data/lib/prawn/text/formatted/wrap.rb +0 -150
- data/lib/prawn/utilities.rb +0 -46
- data/manual/basic_concepts/adding_pages.rb +0 -27
- data/manual/basic_concepts/basic_concepts.rb +0 -34
- data/manual/basic_concepts/creation.rb +0 -39
- data/manual/basic_concepts/cursor.rb +0 -33
- data/manual/basic_concepts/measurement.rb +0 -25
- data/manual/basic_concepts/origin.rb +0 -38
- data/manual/basic_concepts/other_cursor_helpers.rb +0 -40
- data/manual/bounding_box/bounding_box.rb +0 -39
- data/manual/bounding_box/bounds.rb +0 -49
- data/manual/bounding_box/canvas.rb +0 -24
- data/manual/bounding_box/creation.rb +0 -23
- data/manual/bounding_box/indentation.rb +0 -46
- data/manual/bounding_box/nesting.rb +0 -45
- data/manual/bounding_box/russian_boxes.rb +0 -40
- data/manual/bounding_box/stretchy.rb +0 -31
- data/manual/document_and_page_options/background.rb +0 -27
- data/manual/document_and_page_options/document_and_page_options.rb +0 -32
- data/manual/document_and_page_options/metadata.rb +0 -23
- data/manual/document_and_page_options/page_margins.rb +0 -38
- data/manual/document_and_page_options/page_size.rb +0 -34
- data/manual/document_and_page_options/print_scaling.rb +0 -20
- data/manual/example_file.rb +0 -111
- data/manual/example_helper.rb +0 -411
- data/manual/example_package.rb +0 -53
- data/manual/example_section.rb +0 -46
- data/manual/graphics/circle_and_ellipse.rb +0 -22
- data/manual/graphics/color.rb +0 -24
- data/manual/graphics/common_lines.rb +0 -30
- data/manual/graphics/fill_and_stroke.rb +0 -42
- data/manual/graphics/fill_rules.rb +0 -37
- data/manual/graphics/gradients.rb +0 -37
- data/manual/graphics/graphics.rb +0 -58
- data/manual/graphics/helper.rb +0 -24
- data/manual/graphics/line_width.rb +0 -35
- data/manual/graphics/lines_and_curves.rb +0 -41
- data/manual/graphics/polygon.rb +0 -29
- data/manual/graphics/rectangle.rb +0 -21
- data/manual/graphics/rotate.rb +0 -28
- data/manual/graphics/scale.rb +0 -41
- data/manual/graphics/soft_masks.rb +0 -46
- data/manual/graphics/stroke_cap.rb +0 -31
- data/manual/graphics/stroke_dash.rb +0 -48
- data/manual/graphics/stroke_join.rb +0 -30
- data/manual/graphics/translate.rb +0 -29
- data/manual/graphics/transparency.rb +0 -35
- data/manual/images/absolute_position.rb +0 -23
- data/manual/images/fit.rb +0 -21
- data/manual/images/horizontal.rb +0 -25
- data/manual/images/images.rb +0 -40
- data/manual/images/plain_image.rb +0 -18
- data/manual/images/scale.rb +0 -22
- data/manual/images/vertical.rb +0 -28
- data/manual/images/width_and_height.rb +0 -25
- data/manual/layout/boxes.rb +0 -27
- data/manual/layout/content.rb +0 -25
- data/manual/layout/layout.rb +0 -28
- data/manual/layout/simple_grid.rb +0 -23
- data/manual/manual/cover.rb +0 -36
- data/manual/manual/foreword.rb +0 -85
- data/manual/manual/how_to_read_this_manual.rb +0 -41
- data/manual/manual/manual.rb +0 -34
- data/manual/outline/add_subsection_to.rb +0 -61
- data/manual/outline/insert_section_after.rb +0 -47
- data/manual/outline/outline.rb +0 -32
- data/manual/outline/sections_and_pages.rb +0 -67
- data/manual/repeatable_content/page_numbering.rb +0 -54
- data/manual/repeatable_content/repeatable_content.rb +0 -31
- data/manual/repeatable_content/repeater.rb +0 -55
- data/manual/repeatable_content/stamp.rb +0 -41
- data/manual/security/encryption.rb +0 -31
- data/manual/security/permissions.rb +0 -38
- data/manual/security/security.rb +0 -28
- data/manual/syntax_highlight.rb +0 -52
- data/manual/table/basic_block.rb +0 -53
- data/manual/table/before_rendering_page.rb +0 -26
- data/manual/table/cell_border_lines.rb +0 -24
- data/manual/table/cell_borders_and_bg.rb +0 -31
- data/manual/table/cell_dimensions.rb +0 -30
- data/manual/table/cell_text.rb +0 -38
- data/manual/table/column_widths.rb +0 -30
- data/manual/table/content_and_subtables.rb +0 -39
- data/manual/table/creation.rb +0 -27
- data/manual/table/filtering.rb +0 -36
- data/manual/table/flow_and_header.rb +0 -17
- data/manual/table/image_cells.rb +0 -33
- data/manual/table/position.rb +0 -29
- data/manual/table/row_colors.rb +0 -20
- data/manual/table/span.rb +0 -30
- data/manual/table/style.rb +0 -22
- data/manual/table/table.rb +0 -52
- data/manual/table/width.rb +0 -27
- data/manual/text/alignment.rb +0 -44
- data/manual/text/color.rb +0 -24
- data/manual/text/column_box.rb +0 -32
- data/manual/text/fallback_fonts.rb +0 -37
- data/manual/text/font.rb +0 -41
- data/manual/text/font_size.rb +0 -45
- data/manual/text/font_style.rb +0 -23
- data/manual/text/formatted_callbacks.rb +0 -60
- data/manual/text/formatted_text.rb +0 -54
- data/manual/text/free_flowing_text.rb +0 -51
- data/manual/text/group.rb +0 -31
- data/manual/text/inline.rb +0 -43
- data/manual/text/kerning_and_character_spacing.rb +0 -39
- data/manual/text/leading.rb +0 -25
- data/manual/text/line_wrapping.rb +0 -41
- data/manual/text/paragraph_indentation.rb +0 -26
- data/manual/text/positioned_text.rb +0 -38
- data/manual/text/registering_families.rb +0 -48
- data/manual/text/rendering_and_color.rb +0 -37
- data/manual/text/right_to_left_text.rb +0 -43
- data/manual/text/rotation.rb +0 -43
- data/manual/text/single_usage.rb +0 -37
- data/manual/text/text.rb +0 -75
- data/manual/text/text_box_excess.rb +0 -32
- data/manual/text/text_box_extensions.rb +0 -45
- data/manual/text/text_box_overflow.rb +0 -44
- data/manual/text/utf8.rb +0 -28
- data/manual/text/win_ansi_charset.rb +0 -59
- data/spec/acceptance/png.rb +0 -23
- data/spec/column_box_spec.rb +0 -65
- data/spec/extensions/encoding_helpers.rb +0 -9
- data/spec/font_metric_cache_spec.rb +0 -52
- data/spec/image_handler_spec.rb +0 -54
- data/spec/soft_mask_spec.rb +0 -117
- data/spec/table/span_dummy_spec.rb +0 -17
data/COPYING
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
Prawn may be used under Matz's
|
2
|
-
|
1
|
+
Prawn may be used under Matz's terms for Ruby, or GPLv2 or GPLv3. See LICENSE
|
2
|
+
for Matz's terms, or GPLv2 and GPLv3 files.
|
data/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Prawn is copyrighted free software produced by Gregory Brown along with
|
2
2
|
community contributions. See git log for authorship information.
|
3
3
|
|
4
|
-
Licensing terms follow:
|
4
|
+
Licensing terms follow (License of Ruby):
|
5
5
|
|
6
6
|
You can redistribute Prawn and/or modify it under either the terms of the GPLv2
|
7
7
|
or GPLv3 (see GPLv2 and GPLv3 files), or the conditions below:
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Prawn: Fast, Nimble PDF Generation For Ruby
|
2
|
+
|
3
|
+
Prawn is a pure Ruby PDF generation library that provides a lot of great functionality while trying to remain simple and reasonably performant. Here are some of the important features we provide:
|
4
|
+
|
5
|
+
* Vector drawing support, including lines, polygons, curves, ellipses, etc.
|
6
|
+
* Extensive text rendering support, including flowing text and limited inline formatting options.
|
7
|
+
* Support for both PDF builtin fonts as well as embedded TrueType fonts
|
8
|
+
* A variety of low level tools for basic layout needs, including a simple grid system
|
9
|
+
* PNG and JPG image embedding, with flexible scaling options
|
10
|
+
* Reporting tools for rendering complex data tables, with pagination support
|
11
|
+
* Security features including encryption and password protection
|
12
|
+
* Tools for rendering repeatable content (i.e headers, footers, and page numbers)
|
13
|
+
* Comprehensive internationalization features, including full support for UTF-8 based fonts, right-to-left text rendering, fallback font support, and extension points for customizable text wrapping.
|
14
|
+
* Support for PDF outlines for document navigation
|
15
|
+
* Low level PDF features, allowing users to create custom extensions by dropping down all the way to the PDF object tree layer. (Mostly useful to those with knowledge of the PDF specification)
|
16
|
+
* Lots of other stuff!
|
17
|
+
|
18
|
+
## Should You Use Prawn?
|
19
|
+
|
20
|
+
If you are looking for a highly flexible PDF document generation system, Prawn might be the tool for you. It is not a reporting tool or a publishing toolchain, though it could be fairly easily used to build those things.
|
21
|
+
|
22
|
+
One thing Prawn is not, and will never be, is an HTML to PDF generator. For those needs, consider looking into FlyingSaucer via JRuby, or one of the webkit based tools, like Wicked or PDFKit. We do have basic support for inline styling but it is limited to a very small subset of functionality and is not suitable for rendering rich HTML documents.
|
23
|
+
|
24
|
+
## Supported Ruby Versions and Implementations
|
25
|
+
|
26
|
+
Because Prawn is pure Ruby and virtually all of its dependencies are maintained by our core team, it should run pretty much anywhere, including Rubinius, JRuby, MacRuby, etc. While we officially support MRI 1.8.7 and 1.9.2 only, we will accept patches to fix problems on other Ruby platforms if they aren't too invasive.
|
27
|
+
|
28
|
+
## Installing Prawn
|
29
|
+
|
30
|
+
Prawn is distributed via RubyGems, and can be installed the usual way that you install gems: by simply typing `gem install prawn` on the command line.
|
31
|
+
|
32
|
+
You can also install from git if you'd like, the _master_ branch contains the latest developments, and _stable_ represents the latest bug fixes to the currently released version of Prawn. If you go this route, using Bundler is encouraged.
|
33
|
+
|
34
|
+
## Release Policies
|
35
|
+
|
36
|
+
We may introduce backwards incompatible changes each time our minor version number is bumped, but that any tiny version number bump should be bug fixes and internal changes only. Be sure to read the release notes each time we cut a new release and lock your gems accordingly. You can find the project CHANGELOG at: https://github.com/sandal/prawn/wiki/CHANGELOG
|
37
|
+
|
38
|
+
## Hello World!
|
39
|
+
|
40
|
+
If the following code runs and produces a working PDF file, you've successfully installed Prawn.
|
41
|
+
|
42
|
+
require "prawn"
|
43
|
+
|
44
|
+
Prawn::Document.generate("hello.pdf") do
|
45
|
+
text "Hello World!"
|
46
|
+
end
|
47
|
+
|
48
|
+
Of course, you'll probably want to do more interesting things than that...
|
49
|
+
|
50
|
+
## Manual
|
51
|
+
|
52
|
+
Mendicant University student Felipe Doria provided us with a beautiful system for generating a user manual from our examples. This can be generated from the prawn source or you can download a pre-generated snapshot of it at http://prawn.majesticseacreature.com/manual.pdf
|
53
|
+
|
54
|
+
Note that while we will try to keep the downloadable manual up to date, that it's provided as a convenience only and you should generate the manual yourself if you want to be sure the code in it actually runs and works as expected. To build the manual, here's what you need to do:
|
55
|
+
|
56
|
+
1. clone the repository
|
57
|
+
2. switch to the stable branch (optional, stay on master for development version)
|
58
|
+
3. install bundler if necessay
|
59
|
+
4. run `bundle install`
|
60
|
+
5. run `bundle exec rake manual`, which will generate _manual.pdf_ in the project root
|
61
|
+
|
62
|
+
## Support
|
63
|
+
|
64
|
+
The easiest way to get help with Prawn is to post a message to our mailing list:
|
65
|
+
|
66
|
+
<http://groups.google.com/group/prawn-ruby>
|
67
|
+
|
68
|
+
Feel free to post any Prawn related question there, our community is very responsive and will be happy to help you figure out how to use Prawn, or help you determine whether it's the right tool for the task you are working on.
|
69
|
+
|
70
|
+
Please make your posts to the list as specific as possible, including code samples and output where relevant. Do not post any information that should not be shared publicly, and be sure to reduce your example code as much as possible so that those who are responding to your question can more easily see what the issue might be.
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
If you've found a bug, want to submit a patch, or have a feature request, please enter a ticket into our github tracker:
|
75
|
+
|
76
|
+
<http://github.com/sandal/prawn/issues>
|
77
|
+
|
78
|
+
We strongly encourage bug reports to come with failing tests or at least a reduced example that demonstrates the problem. Similarly, patches should include tests, API documentation, and an update to the manual where relevant. Feel free to send a pull request early though, if you just want some feedback or a code review before preparing your code to be merged.
|
79
|
+
|
80
|
+
If you are unsure about whether or not you've found a bug, or want to check to see whether we'd be interested in the feature you want to add before you start working on it, feel free to post to our mailing list.
|
81
|
+
|
82
|
+
## Authorship
|
83
|
+
|
84
|
+
Prawn was originally developed by Gregory Brown, under the auspices of the Ruby Mendicant Project, a grassroots initiative in which the Ruby community collectively provided funding so that Gregory could take several months off of work to focus on this project.
|
85
|
+
|
86
|
+
Over the last several years, we've received code contributions from over 50 people, which is amazing considering the low-level nature of this project. In 2010, Gregory officially handed the project off to the Prawn core team. Currently active maintainers include Brad Ediger, Daniel Nelson, James Healy, and Jonathan Greenberg.
|
87
|
+
|
88
|
+
While he was only with us for a short time before moving on to other things, we'd also like to thank Prawn core team emeritus Jamis Buck for his contributions. He was responsible for introducing font subsetting as well as the first implementation of our inline formatting support.
|
89
|
+
|
90
|
+
You can find the full list of folks who have at least one patch accepted to Prawn on github at https://github.com/sandal/prawn/contributors
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
Prawn is released under a slightly modified form of the License of Ruby, allowing you to choose between Matz's terms, the GPLv2, or GPLv3. For details, please see the LICENSE, GPLv2, and GPLv3 files.
|
95
|
+
|
96
|
+
If you wish to contribute to Prawn, you will retain your own copyright but must agree to license your code under the same terms as the project itself.
|
data/Rakefile
CHANGED
@@ -1,31 +1,40 @@
|
|
1
|
+
require "rubygems"
|
1
2
|
require "bundler"
|
2
3
|
Bundler.setup
|
3
4
|
|
4
5
|
require 'rake'
|
5
|
-
require '
|
6
|
-
require
|
7
|
-
require
|
8
|
-
|
9
|
-
task :default => [:
|
10
|
-
|
11
|
-
desc "Run all
|
12
|
-
|
13
|
-
|
6
|
+
require 'rake/testtask'
|
7
|
+
require "rake/rdoctask"
|
8
|
+
require "rake/gempackagetask"
|
9
|
+
|
10
|
+
task :default => [:test]
|
11
|
+
|
12
|
+
desc "Run all tests, test-spec, mocha, and pdf-reader required"
|
13
|
+
Rake::TestTask.new do |test|
|
14
|
+
# test.ruby_opts << "-w" # .should == true triggers a lot of warnings
|
15
|
+
test.libs << "spec"
|
16
|
+
test.test_files = Dir[ "spec/*_spec.rb" ]
|
17
|
+
test.verbose = true
|
14
18
|
end
|
15
19
|
|
16
20
|
desc "Show library's code statistics"
|
17
21
|
task :stats do
|
18
|
-
|
19
|
-
CodeStatistics::TEST_TYPES << "Specs"
|
20
|
-
|
21
|
-
|
22
|
+
require 'code_statistics'
|
23
|
+
CodeStatistics::TEST_TYPES << "Specs"
|
24
|
+
CodeStatistics.new( ["Prawn", "lib"],
|
25
|
+
["Specs", "spec"] ).to_s
|
22
26
|
end
|
23
27
|
|
24
|
-
|
25
|
-
|
28
|
+
desc "genrates documentation"
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
rdoc.rdoc_files.include( "README",
|
31
|
+
"COPYING",
|
32
|
+
"LICENSE",
|
33
|
+
"HACKING", "lib/" )
|
34
|
+
rdoc.main = "README"
|
35
|
+
rdoc.rdoc_dir = "doc/html"
|
36
|
+
rdoc.title = "Prawn Documentation"
|
26
37
|
end
|
27
|
-
task :docs => :yard
|
28
|
-
|
29
38
|
|
30
39
|
desc "Generate the 'Prawn by Example' manual"
|
31
40
|
task :manual do
|
@@ -36,19 +45,7 @@ task :manual do
|
|
36
45
|
end
|
37
46
|
|
38
47
|
spec = Gem::Specification.load "prawn.gemspec"
|
39
|
-
|
48
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
40
49
|
pkg.need_zip = true
|
41
50
|
pkg.need_tar = true
|
42
51
|
end
|
43
|
-
|
44
|
-
desc "Run a console with Prawn loaded"
|
45
|
-
task :console do
|
46
|
-
require 'irb'
|
47
|
-
require 'irb/completion'
|
48
|
-
require_relative 'lib/prawn'
|
49
|
-
Prawn.debug = true
|
50
|
-
|
51
|
-
ARGV.clear
|
52
|
-
IRB.start
|
53
|
-
end
|
54
|
-
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/data/images/16bit.alpha
CHANGED
Binary file
|
Binary file
|
data/data/images/dice.alpha
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/data/pdfs/nested_pages.pdf
CHANGED
@@ -49,7 +49,7 @@ endobj
|
|
49
49
|
>>
|
50
50
|
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
51
51
|
>>
|
52
|
-
/Parent
|
52
|
+
/Parent 4 0 R
|
53
53
|
>>
|
54
54
|
endobj
|
55
55
|
7 0 obj
|
@@ -85,7 +85,7 @@ endobj
|
|
85
85
|
>>
|
86
86
|
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
87
87
|
>>
|
88
|
-
/Parent
|
88
|
+
/Parent 4 0 R
|
89
89
|
>>
|
90
90
|
endobj
|
91
91
|
10 0 obj
|
@@ -97,17 +97,17 @@ endobj
|
|
97
97
|
endobj
|
98
98
|
xref
|
99
99
|
0 11
|
100
|
-
0000000000 65535 f
|
101
|
-
0000000015 00000 n
|
102
|
-
0000000071 00000 n
|
103
|
-
0000000120 00000 n
|
104
|
-
0000000183 00000 n
|
105
|
-
0000000240 00000 n
|
106
|
-
0000000494 00000 n
|
107
|
-
0000000672 00000 n
|
108
|
-
0000000769 00000 n
|
109
|
-
0000000994 00000 n
|
110
|
-
0000001173 00000 n
|
100
|
+
0000000000 65535 f
|
101
|
+
0000000015 00000 n
|
102
|
+
0000000071 00000 n
|
103
|
+
0000000120 00000 n
|
104
|
+
0000000183 00000 n
|
105
|
+
0000000240 00000 n
|
106
|
+
0000000494 00000 n
|
107
|
+
0000000672 00000 n
|
108
|
+
0000000769 00000 n
|
109
|
+
0000000994 00000 n
|
110
|
+
0000001173 00000 n
|
111
111
|
trailer
|
112
112
|
<< /Root 2 0 R
|
113
113
|
/Size 11
|
data/lib/prawn.rb
CHANGED
@@ -1,91 +1,27 @@
|
|
1
1
|
# Welcome to Prawn, the best PDF Generation library ever.
|
2
2
|
# This documentation covers user level functionality.
|
3
3
|
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
module Prawn
|
10
|
-
VERSION = "0.15.0"
|
11
|
-
|
12
|
-
extend self
|
13
|
-
|
14
|
-
file = __FILE__
|
15
|
-
file = File.readlink(file) if File.symlink?(file)
|
16
|
-
dir = File.dirname(file)
|
17
|
-
|
18
|
-
# The base source directory for Prawn as installed on the system
|
19
|
-
#
|
20
|
-
#
|
21
|
-
BASEDIR = File.expand_path(File.join(dir, '..'))
|
22
|
-
DATADIR = File.expand_path(File.join(dir, '..', 'data'))
|
23
|
-
|
24
|
-
FLOAT_PRECISION = 1.0e-9
|
25
|
-
|
26
|
-
# Whe set to true, Prawn will verify hash options to ensure only valid keys
|
27
|
-
# are used. Off by default.
|
28
|
-
#
|
29
|
-
# Example:
|
30
|
-
# >> Prawn::Document.new(:tomato => "Juicy")
|
31
|
-
# Prawn::Errors::UnknownOption:
|
32
|
-
# Detected unknown option(s): [:tomato]
|
33
|
-
# Accepted options are: [:page_size, :page_layout, :left_margin, ...]
|
34
|
-
#
|
35
|
-
attr_accessor :debug # @private
|
36
|
-
|
37
|
-
def verify_options(accepted, actual) # @private
|
38
|
-
return unless debug || $DEBUG
|
39
|
-
unless (act=Set[*actual.keys]).subset?(acc=Set[*accepted])
|
40
|
-
raise Prawn::Errors::UnknownOption,
|
41
|
-
"\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n" <<
|
42
|
-
"Accepted options are: #{accepted.inspect}"
|
43
|
-
end
|
44
|
-
yield if block_given?
|
45
|
-
end
|
46
|
-
|
47
|
-
module Configurable # @private
|
48
|
-
def configuration(*args)
|
49
|
-
@config ||= Marshal.load(Marshal.dump(default_configuration))
|
50
|
-
if Hash === args[0]
|
51
|
-
@config.update(args[0])
|
52
|
-
elsif args.length > 1
|
53
|
-
@config.values_at(*args)
|
54
|
-
elsif args.length == 1
|
55
|
-
@config[args[0]]
|
56
|
-
else
|
57
|
-
@config
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
alias_method :C, :configuration
|
62
|
-
end
|
4
|
+
# Those looking to contribute code or write extensions should look
|
5
|
+
# into the lib/prawn/core/* source tree.
|
6
|
+
#
|
7
|
+
module Prawn #:nodoc:
|
8
|
+
VERSION = "1.0.0.rc1"
|
63
9
|
end
|
64
10
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
require_relative "prawn/measurements"
|
82
|
-
require_relative "prawn/repeater"
|
83
|
-
require_relative "prawn/outline"
|
84
|
-
require_relative "prawn/layout"
|
85
|
-
|
86
|
-
require_relative "prawn/image_handler"
|
87
|
-
|
88
|
-
|
11
|
+
require "prawn/core"
|
12
|
+
require "prawn/text"
|
13
|
+
require "prawn/graphics"
|
14
|
+
require "prawn/images"
|
15
|
+
require "prawn/images/image"
|
16
|
+
require "prawn/images/jpg"
|
17
|
+
require "prawn/images/png"
|
18
|
+
require "prawn/stamp"
|
19
|
+
require "prawn/security"
|
20
|
+
require "prawn/document"
|
21
|
+
require "prawn/font"
|
22
|
+
require "prawn/encoding"
|
23
|
+
require "prawn/measurements"
|
24
|
+
require "prawn/repeater"
|
25
|
+
require "prawn/outline"
|
26
|
+
require "prawn/layout"
|
89
27
|
|
90
|
-
Prawn.image_handler.register(Prawn::Images::PNG)
|
91
|
-
Prawn.image_handler.register(Prawn::Images::JPG)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Why would we ever use Ruby 1.8.7 when we can backport with something
|
4
|
+
# as simple as this?
|
5
|
+
#
|
6
|
+
class String #:nodoc:
|
7
|
+
def first_line
|
8
|
+
self.each_line { |line| return line }
|
9
|
+
end
|
10
|
+
unless "".respond_to?(:lines)
|
11
|
+
alias_method :lines, :to_a
|
12
|
+
end
|
13
|
+
unless "".respond_to?(:each_char)
|
14
|
+
def each_char #:nodoc:
|
15
|
+
# copied from jcode
|
16
|
+
if block_given?
|
17
|
+
scan(/./m) { |x| yield x }
|
18
|
+
else
|
19
|
+
scan(/./m)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
unless File.respond_to?(:binread)
|
26
|
+
def File.binread(file) #:nodoc:
|
27
|
+
File.open(file,"rb") { |f| f.read }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if RUBY_VERSION < "1.9"
|
32
|
+
|
33
|
+
def ruby_18 #:nodoc:
|
34
|
+
yield
|
35
|
+
end
|
36
|
+
|
37
|
+
def ruby_19 #:nodoc:
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
41
|
+
else
|
42
|
+
|
43
|
+
def ruby_18 #:nodoc:
|
44
|
+
false
|
45
|
+
end
|
46
|
+
|
47
|
+
def ruby_19 #:nodoc:
|
48
|
+
yield
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/prawn/core.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Prawn : A library for PDF generation in Ruby
|
3
|
+
#
|
4
|
+
# Copyright April 2008, Gregory Brown. All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This is free software. Please see the LICENSE and COPYING files for details.
|
7
|
+
|
8
|
+
require "set"
|
9
|
+
|
10
|
+
%w[ttfunk/lib].each do |dep|
|
11
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../../vendor/#{dep}")
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
require 'ttfunk'
|
16
|
+
rescue LoadError
|
17
|
+
puts "Failed to load ttfunk. If you are running Prawn from git:"
|
18
|
+
puts " git submodule init"
|
19
|
+
puts " git submodule update"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
module Prawn
|
24
|
+
extend self
|
25
|
+
|
26
|
+
file = __FILE__
|
27
|
+
file = File.readlink(file) if File.symlink?(file)
|
28
|
+
dir = File.dirname(file)
|
29
|
+
|
30
|
+
# The base source directory for Prawn as installed on the system
|
31
|
+
#
|
32
|
+
BASEDIR = File.expand_path(File.join(dir, '..', '..'))
|
33
|
+
|
34
|
+
# Whe set to true, Prawn will verify hash options to ensure only valid keys
|
35
|
+
# are used. Off by default.
|
36
|
+
#
|
37
|
+
# Example:
|
38
|
+
# >> Prawn::Document.new(:tomato => "Juicy")
|
39
|
+
# Prawn::Errors::UnknownOption:
|
40
|
+
# Detected unknown option(s): [:tomato]
|
41
|
+
# Accepted options are: [:page_size, :page_layout, :left_margin, ...]
|
42
|
+
#
|
43
|
+
attr_accessor :debug
|
44
|
+
|
45
|
+
def verify_options(accepted, actual) #:nodoc:
|
46
|
+
return unless debug || $DEBUG
|
47
|
+
unless (act=Set[*actual.keys]).subset?(acc=Set[*accepted])
|
48
|
+
raise Prawn::Errors::UnknownOption,
|
49
|
+
"\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n" <<
|
50
|
+
"Accepted options are: #{accepted.inspect}"
|
51
|
+
end
|
52
|
+
yield if block_given?
|
53
|
+
end
|
54
|
+
|
55
|
+
module Configurable #:nodoc:
|
56
|
+
def configuration(*args)
|
57
|
+
@config ||= Marshal.load(Marshal.dump(default_configuration))
|
58
|
+
if Hash === args[0]
|
59
|
+
@config.update(args[0])
|
60
|
+
elsif args.length > 1
|
61
|
+
@config.values_at(*args)
|
62
|
+
elsif args.length == 1
|
63
|
+
@config[args[0]]
|
64
|
+
else
|
65
|
+
@config
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
alias_method :C, :configuration
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
require "prawn/compatibility"
|
74
|
+
require "prawn/errors"
|
75
|
+
require "prawn/core/pdf_object"
|
76
|
+
require "prawn/core/reference"
|
77
|
+
require "prawn/core/page"
|
78
|
+
require "prawn/core/object_store"
|
79
|
+
require "prawn/core/document_state"
|
80
|
+
require "prawn/core/literal_string"
|
81
|
+
require "prawn/core/byte_string"
|
82
|
+
require "prawn/core/name_tree"
|
83
|
+
require "prawn/core/annotations"
|
84
|
+
require "prawn/core/destinations"
|
85
|
+
|