prawn 0.11.1.pre → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +2 -340
- data/HACKING +1 -1
- data/LICENSE +3 -3
- data/Rakefile +17 -6
- data/data/encodings/win_ansi.txt +1 -1
- data/data/images/prawn.png +0 -0
- data/data/pdfs/form.pdf +820 -0
- data/data/pdfs/multipage_template.pdf +127 -0
- data/examples/bounding_box/bounding_boxes.rb +4 -3
- data/examples/bounding_box/indentation.rb +2 -1
- data/examples/bounding_box/russian_boxes.rb +3 -2
- data/examples/bounding_box/stretched_nesting.rb +2 -1
- data/examples/general/background.rb +2 -1
- data/examples/general/canvas.rb +2 -1
- data/examples/general/context_sensitive_headers.rb +2 -1
- data/examples/general/float.rb +2 -1
- data/examples/general/margin.rb +2 -1
- data/examples/general/measurement_units.rb +2 -1
- data/examples/general/metadata-info.rb +2 -1
- data/examples/general/multi_page_layout.rb +2 -1
- data/examples/general/outlines.rb +2 -1
- data/examples/general/page_geometry.rb +2 -1
- data/examples/general/page_numbering.rb +27 -2
- data/examples/general/page_templates.rb +20 -0
- data/examples/general/repeaters.rb +2 -1
- data/examples/general/stamp.rb +4 -3
- data/examples/general/templates.rb +2 -1
- data/examples/graphics/basic_images.rb +2 -1
- data/examples/graphics/cmyk.rb +2 -1
- data/examples/graphics/curves.rb +4 -3
- data/examples/graphics/gradient.rb +23 -0
- data/examples/graphics/hexagon.rb +3 -2
- data/examples/graphics/image_fit.rb +3 -2
- data/examples/graphics/image_flow.rb +2 -1
- data/examples/graphics/image_position.rb +3 -2
- data/examples/graphics/line.rb +2 -1
- data/examples/graphics/png_types.rb +3 -2
- data/examples/graphics/polygons.rb +3 -2
- data/examples/graphics/remote_images.rb +2 -1
- data/examples/graphics/rounded_polygons.rb +2 -1
- data/examples/graphics/rounded_rectangle.rb +2 -1
- data/examples/graphics/ruport_style_helpers.rb +3 -2
- data/examples/graphics/stroke_bounds.rb +2 -1
- data/examples/graphics/stroke_cap_and_join.rb +2 -1
- data/examples/graphics/stroke_dash.rb +2 -1
- data/examples/graphics/transformations.rb +2 -1
- data/examples/graphics/transparency.rb +4 -3
- data/examples/grid/bounding_boxes.rb +2 -1
- data/examples/grid/column_gutter_grid.rb +2 -1
- data/examples/grid/multi_boxes.rb +2 -1
- data/examples/grid/show_grid.rb +2 -1
- data/examples/grid/simple_grid.rb +2 -1
- data/examples/m17n/chinese_text_wrapping.rb +2 -1
- data/examples/m17n/euro.rb +3 -2
- data/examples/m17n/full_win_ansi_character_list.rb +20 -0
- data/examples/m17n/sjis.rb +2 -1
- data/examples/m17n/utf8.rb +3 -2
- data/examples/m17n/win_ansi_charset.rb +2 -1
- data/examples/security/hello_foo.rb +2 -1
- data/examples/table/bill.rb +2 -1
- data/examples/table/borders.rb +25 -0
- data/examples/table/cell.rb +3 -2
- data/examples/table/checkerboard.rb +2 -1
- data/examples/table/header.rb +3 -2
- data/examples/table/inline_format_table.rb +2 -1
- data/examples/table/multi_page_table.rb +2 -1
- data/examples/table/simple_table.rb +2 -1
- data/examples/table/subtable.rb +2 -1
- data/examples/table/widths.rb +2 -1
- data/examples/text/alignment.rb +2 -1
- data/examples/text/character_spacing.rb +2 -1
- data/examples/text/dfont.rb +2 -1
- data/examples/text/family_based_styling.rb +3 -2
- data/examples/text/font_calculations.rb +2 -1
- data/examples/text/font_size.rb +2 -1
- data/examples/text/hyphenation.rb +2 -2
- data/examples/text/indent_paragraphs.rb +7 -5
- data/examples/text/inline_format.rb +7 -6
- data/examples/text/kerning.rb +2 -1
- data/examples/text/rendering_mode.rb +21 -0
- data/examples/text/rotated.rb +2 -1
- data/examples/text/shaped_text_box.rb +2 -1
- data/examples/text/simple_text.rb +2 -1
- data/examples/text/simple_text_ttf.rb +2 -1
- data/examples/text/span.rb +3 -2
- data/examples/text/text_box.rb +7 -5
- data/examples/text/text_box_returning_excess.rb +4 -3
- data/examples/text/text_flow.rb +2 -1
- data/lib/prawn.rb +1 -1
- data/lib/prawn/core/object_store.rb +42 -14
- data/lib/prawn/core/page.rb +22 -8
- data/lib/prawn/core/text.rb +141 -13
- data/lib/prawn/core/text/formatted/arranger.rb +39 -12
- data/lib/prawn/core/text/formatted/line_wrap.rb +205 -60
- data/lib/prawn/core/text/formatted/wrap.rb +72 -35
- data/lib/prawn/document.rb +174 -70
- data/lib/prawn/document/bounding_box.rb +122 -83
- data/lib/prawn/document/column_box.rb +113 -0
- data/lib/prawn/document/graphics_state.rb +90 -2
- data/lib/prawn/document/internals.rb +5 -3
- data/lib/prawn/errors.rb +5 -0
- data/lib/prawn/font.rb +4 -4
- data/lib/prawn/font/afm.rb +11 -0
- data/lib/prawn/font/ttf.rb +5 -0
- data/lib/prawn/graphics.rb +77 -14
- data/lib/prawn/graphics/cap_style.rb +13 -5
- data/lib/prawn/graphics/color.rb +54 -35
- data/lib/prawn/graphics/dash.rb +27 -16
- data/lib/prawn/graphics/gradient.rb +84 -0
- data/lib/prawn/graphics/join_style.rb +12 -3
- data/lib/prawn/graphics/transparency.rb +4 -4
- data/lib/prawn/images.rb +18 -160
- data/lib/prawn/images/jpg.rb +39 -0
- data/lib/prawn/images/png.rb +130 -0
- data/lib/prawn/repeater.rb +6 -13
- data/lib/prawn/security.rb +6 -1
- data/lib/prawn/stamp.rb +12 -4
- data/lib/prawn/table.rb +36 -4
- data/lib/prawn/table/cell.rb +224 -63
- data/lib/prawn/table/cell/text.rb +20 -10
- data/lib/prawn/table/cells.rb +23 -6
- data/lib/prawn/text.rb +54 -91
- data/lib/prawn/text/box.rb +29 -283
- data/lib/prawn/text/formatted/box.rb +349 -24
- data/lib/prawn/text/formatted/fragment.rb +63 -2
- data/lib/prawn/text/formatted/parser.rb +2 -1
- data/prawn.gemspec +21 -5
- data/spec/bounding_box_spec.rb +61 -28
- data/spec/cell_spec.rb +168 -30
- data/spec/document_spec.rb +187 -3
- data/spec/extensions/mocha.rb +45 -0
- data/spec/font_spec.rb +32 -1
- data/spec/formatted_text_arranger_spec.rb +35 -40
- data/spec/formatted_text_box_spec.rb +287 -443
- data/spec/formatted_text_fragment_spec.rb +87 -0
- data/spec/graphics_spec.rb +128 -12
- data/spec/grid_spec.rb +1 -1
- data/spec/images_spec.rb +11 -3
- data/spec/inline_formatted_text_parser_spec.rb +8 -0
- data/spec/line_wrap_spec.rb +200 -208
- data/spec/object_store_spec.rb +10 -0
- data/spec/outline_spec.rb +7 -3
- data/spec/repeater_spec.rb +58 -10
- data/spec/security_spec.rb +6 -0
- data/spec/spec_helper.rb +12 -8
- data/spec/stamp_spec.rb +52 -1
- data/spec/stroke_styles_spec.rb +30 -0
- data/spec/table_spec.rb +93 -3
- data/spec/template_spec.rb +132 -6
- data/spec/text_at_spec.rb +14 -4
- data/spec/text_box_spec.rb +309 -70
- data/spec/text_rendering_mode_spec.rb +45 -0
- data/spec/text_spec.rb +60 -17
- data/spec/text_with_inline_formatting_spec.rb +4 -162
- metadata +241 -241
- data/lib/prawn/core/text/line_wrap.rb +0 -211
- data/lib/prawn/core/text/wrap.rb +0 -82
- data/vendor/pdf-inspector/README +0 -18
- data/vendor/pdf-inspector/lib/pdf/inspector.rb +0 -26
- data/vendor/pdf-inspector/lib/pdf/inspector/extgstate.rb +0 -18
- data/vendor/pdf-inspector/lib/pdf/inspector/graphics.rb +0 -131
- data/vendor/pdf-inspector/lib/pdf/inspector/page.rb +0 -25
- data/vendor/pdf-inspector/lib/pdf/inspector/text.rb +0 -46
- data/vendor/pdf-inspector/lib/pdf/inspector/xobject.rb +0 -19
- data/vendor/ttfunk/data/fonts/DejaVuSans.ttf +0 -0
- data/vendor/ttfunk/data/fonts/comicsans.ttf +0 -0
- data/vendor/ttfunk/example.rb +0 -45
- data/vendor/ttfunk/lib/ttfunk.rb +0 -102
- data/vendor/ttfunk/lib/ttfunk/directory.rb +0 -17
- data/vendor/ttfunk/lib/ttfunk/encoding/mac_roman.rb +0 -88
- data/vendor/ttfunk/lib/ttfunk/encoding/windows_1252.rb +0 -69
- data/vendor/ttfunk/lib/ttfunk/reader.rb +0 -44
- data/vendor/ttfunk/lib/ttfunk/resource_file.rb +0 -78
- data/vendor/ttfunk/lib/ttfunk/subset.rb +0 -18
- data/vendor/ttfunk/lib/ttfunk/subset/base.rb +0 -141
- data/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb +0 -50
- data/vendor/ttfunk/lib/ttfunk/subset/unicode.rb +0 -48
- data/vendor/ttfunk/lib/ttfunk/subset/unicode_8bit.rb +0 -63
- data/vendor/ttfunk/lib/ttfunk/subset/windows_1252.rb +0 -55
- data/vendor/ttfunk/lib/ttfunk/subset_collection.rb +0 -72
- data/vendor/ttfunk/lib/ttfunk/table.rb +0 -46
- data/vendor/ttfunk/lib/ttfunk/table/cmap.rb +0 -34
- data/vendor/ttfunk/lib/ttfunk/table/cmap/format00.rb +0 -54
- data/vendor/ttfunk/lib/ttfunk/table/cmap/format04.rb +0 -126
- data/vendor/ttfunk/lib/ttfunk/table/cmap/subtable.rb +0 -79
- data/vendor/ttfunk/lib/ttfunk/table/glyf.rb +0 -64
- data/vendor/ttfunk/lib/ttfunk/table/glyf/compound.rb +0 -81
- data/vendor/ttfunk/lib/ttfunk/table/glyf/simple.rb +0 -37
- data/vendor/ttfunk/lib/ttfunk/table/head.rb +0 -44
- data/vendor/ttfunk/lib/ttfunk/table/hhea.rb +0 -41
- data/vendor/ttfunk/lib/ttfunk/table/hmtx.rb +0 -47
- data/vendor/ttfunk/lib/ttfunk/table/kern.rb +0 -79
- data/vendor/ttfunk/lib/ttfunk/table/kern/format0.rb +0 -62
- data/vendor/ttfunk/lib/ttfunk/table/loca.rb +0 -43
- data/vendor/ttfunk/lib/ttfunk/table/maxp.rb +0 -40
- data/vendor/ttfunk/lib/ttfunk/table/name.rb +0 -125
- data/vendor/ttfunk/lib/ttfunk/table/os2.rb +0 -78
- data/vendor/ttfunk/lib/ttfunk/table/post.rb +0 -91
- data/vendor/ttfunk/lib/ttfunk/table/post/format10.rb +0 -43
- data/vendor/ttfunk/lib/ttfunk/table/post/format20.rb +0 -35
- data/vendor/ttfunk/lib/ttfunk/table/post/format25.rb +0 -23
- data/vendor/ttfunk/lib/ttfunk/table/post/format30.rb +0 -17
- data/vendor/ttfunk/lib/ttfunk/table/post/format40.rb +0 -17
- data/vendor/ttfunk/lib/ttfunk/table/simple.rb +0 -14
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Draws and fills a Hexagon using Document#polygon
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
pdf = Prawn::Document.new
|
8
9
|
|
@@ -10,4 +11,4 @@ pdf.fill_color "ff0000"
|
|
10
11
|
pdf.fill_polygon [100, 250], [200, 300], [300, 250],
|
11
12
|
[300, 150], [200, 100], [100, 150]
|
12
13
|
|
13
|
-
pdf.render_file "hexagon.pdf"
|
14
|
+
pdf.render_file "hexagon.pdf"
|
@@ -4,7 +4,8 @@
|
|
4
4
|
# The image will be scaled down to fit within the box, while preserving
|
5
5
|
# the aspect ratio.
|
6
6
|
#
|
7
|
-
require
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
%w[.. example_helper]))
|
8
9
|
|
9
10
|
Prawn::Document.generate("image_fit.pdf", :page_layout => :landscape) do
|
10
11
|
|
@@ -12,4 +13,4 @@ Prawn::Document.generate("image_fit.pdf", :page_layout => :landscape) do
|
|
12
13
|
stroke_rectangle [50,450], 200, 200
|
13
14
|
image pigs, :at => [50,450], :fit => [200,200]
|
14
15
|
|
15
|
-
end
|
16
|
+
end
|
@@ -5,7 +5,8 @@
|
|
5
5
|
# useful when used in combination with flowing text, where the exact final
|
6
6
|
# position of the image is not known ahead of time.
|
7
7
|
#
|
8
|
-
require
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
+
%w[.. example_helper]))
|
9
10
|
|
10
11
|
Prawn::Document.generate("image-flow.pdf", :page_layout => :landscape) do
|
11
12
|
self.font_size = 8
|
@@ -2,8 +2,9 @@
|
|
2
2
|
#
|
3
3
|
# Demonstrates vertical and horizontal positioning of images.
|
4
4
|
#
|
5
|
-
require
|
6
|
-
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
7
|
+
|
7
8
|
Prawn::Document.generate("image_position.pdf", :page_layout => :landscape) do
|
8
9
|
|
9
10
|
dice = "#{Prawn::BASEDIR}/data/images/dice.png"
|
data/examples/graphics/line.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# The very first Prawn example. Here for nostalgia's sake.
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
pdf = Prawn::Document.new
|
8
9
|
pdf.line_width = 10
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# PNG files come in different flavours - 5 of them. This example embeds
|
4
4
|
# one of each type as proof that they all work.
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
images = [
|
9
10
|
["Type 0", "#{Prawn::BASEDIR}/data/images/web-links.png"],
|
@@ -19,4 +20,4 @@ Prawn::Document.generate("png_types.pdf", :page_size => "A5") do
|
|
19
20
|
text header
|
20
21
|
image file, :at => [50,450]
|
21
22
|
end
|
22
|
-
end
|
23
|
+
end
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Basic polygon drawing example. See also: hexagon.rb
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
pdf = Prawn::Document.new
|
8
9
|
|
@@ -13,4 +14,4 @@ pdf = Prawn::Document.new
|
|
13
14
|
pdf.stroke_rectangle [0,600], 5*i, 10*i
|
14
15
|
end
|
15
16
|
|
16
|
-
pdf.render_file "pretty_polygons.pdf"
|
17
|
+
pdf.render_file "pretty_polygons.pdf"
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# Rounded rectangle example demonstrating both stroke and stroke and fill.
|
4
4
|
# A rectangle with rounded join_style is added just for comparison.
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
pdf = Prawn::Document.new
|
9
10
|
pdf.font_size 8
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# These helpers will be familiar to Ruport users, and now are supported
|
4
4
|
# directly in Prawn. Run the example to see how they work.
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
# Demonstrates some features stolen from Ruport::Formatter::PDF
|
9
10
|
Prawn::Document.generate("ruport.pdf") do
|
@@ -16,4 +17,4 @@ Prawn::Document.generate("ruport.pdf") do
|
|
16
17
|
stroke_horizontal_line 50, 100
|
17
18
|
stroke_horizontal_line 50, 100, :at => 300
|
18
19
|
stroke_vertical_line 300, 50, :at => 250
|
19
|
-
end
|
20
|
+
end
|
@@ -8,7 +8,8 @@
|
|
8
8
|
# Feature borrowed from Josh Knowle's pt at:
|
9
9
|
# http://github.com/joshknowles/pt/tree/master
|
10
10
|
#
|
11
|
-
require
|
11
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
12
|
+
%w[.. example_helper]))
|
12
13
|
|
13
14
|
Prawn::Document.generate("stroke_bounds.pdf") do
|
14
15
|
stroke_bounds
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Stroke dashing can be applied to any line or curve
|
4
4
|
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
Prawn::Document.generate("stroke_cap_and_join.pdf") do
|
8
9
|
self.line_width = 25
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Stroke dashing can be applied to any line or curve
|
4
4
|
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
Prawn::Document.generate("stroke_dash.pdf") do
|
8
9
|
self.line_width = 1
|
@@ -2,15 +2,16 @@
|
|
2
2
|
#
|
3
3
|
# Demonstrate use of transparency
|
4
4
|
#
|
5
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
6
|
+
%w[.. example_helper]))
|
6
7
|
|
7
8
|
Prawn::Document.generate("transparency.pdf") do
|
8
9
|
fill_color("ff0000")
|
9
|
-
|
10
|
+
fill_circle([200, 200], 200)
|
10
11
|
transparent(0.5, 1) do
|
11
12
|
fill_color("000000")
|
12
13
|
stroke_color("ffffff")
|
13
|
-
|
14
|
+
fill_and_stroke_circle([300, 300], 200)
|
14
15
|
fill_color("ffffff")
|
15
16
|
text "transparency " * 150, :size => 18
|
16
17
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
+
%w[.. example_helper]))
|
4
5
|
|
5
6
|
Prawn::Document.generate('bounding_box_grid.pdf') do |p|
|
6
7
|
p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
+
%w[.. example_helper]))
|
4
5
|
|
5
6
|
Prawn::Document.generate('column_gutter_grid.pdf') do |p|
|
6
7
|
p.define_grid(:columns => 3, :rows => 10, :column_gutter => 10)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
+
%w[.. example_helper]))
|
4
5
|
|
5
6
|
Prawn::Document.generate('multi_boxes.pdf') do |p|
|
6
7
|
p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
|
data/examples/grid/show_grid.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
+
%w[.. example_helper]))
|
4
5
|
|
5
6
|
Prawn::Document.generate('show_grid.pdf') do |p|
|
6
7
|
p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
+
%w[.. example_helper]))
|
4
5
|
|
5
6
|
Prawn::Document.generate('simple_grid.pdf') do |p|
|
6
7
|
p.define_grid(:columns => 5, :rows => 8, :gutter => 10)
|
data/examples/m17n/euro.rb
CHANGED
@@ -8,8 +8,9 @@
|
|
8
8
|
# If you need precision spacing, use a TTF file instead and the issue will
|
9
9
|
# go away.
|
10
10
|
#
|
11
|
-
require
|
11
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
12
|
+
%w[.. example_helper]))
|
12
13
|
|
13
14
|
Prawn::Document.generate "euro.pdf" do
|
14
15
|
text "A Euro! € ©", :size => 32
|
15
|
-
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
3
|
+
%w[.. example_helper]))
|
4
|
+
|
5
|
+
FONT_SIZE = 9.5
|
6
|
+
|
7
|
+
Prawn::Document.generate("missing-win-ansi-mappings.pdf") do
|
8
|
+
# I generated this as a test to see what characters were missing from
|
9
|
+
# data/encodings/win_ansi.txt. To find missing characters, search for
|
10
|
+
# underscore (_). Any underscore except for #95 is a missing encoding.
|
11
|
+
#
|
12
|
+
# http://www.alanwood.net/demos/ansi.html was a helpful list of WinAnsi and
|
13
|
+
# corresponding Unicode hex values for any characters that were missing
|
14
|
+
|
15
|
+
a = [[32, " "], [33, "!"], [34, "\""], [35, "#"], [36, "$"], [37, "%"], [38, "&"], [39, "'"], [40, "("], [41, ")"], [42, "*"], [43, "+"], [44, ","], [45, "-"], [46, "."], [47, "/"], [48, "0"], [49, "1"], [50, "2"], [51, "3"], [52, "4"], [53, "5"], [54, "6"], [55, "7"], [56, "8"], [57, "9"], [58, ":"], [59, ";"], [60, "<"], [61, "="], [62, ">"], [63, "?"], [64, "@"], [65, "A"], [66, "B"], [67, "C"], [68, "D"], [69, "E"], [70, "F"], [71, "G"], [72, "H"], [73, "I"], [74, "J"], [75, "K"], [76, "L"], [77, "M"], [78, "N"], [79, "O"], [80, "P"], [81, "Q"], [82, "R"], [83, "S"], [84, "T"], [85, "U"], [86, "V"], [87, "W"], [88, "X"], [89, "Y"], [90, "Z"], [91, "["], [92, "\\"], [93, "]"], [94, "^"], [95, "_"], [96, "`"], [97, "a"], [98, "b"], [99, "c"], [100, "d"], [101, "e"], [102, "f"], [103, "g"], [104, "h"], [105, "i"], [106, "j"], [107, "k"], [108, "l"], [109, "m"], [110, "n"], [111, "o"], [112, "p"], [113, "q"], [114, "r"], [115, "s"], [116, "t"], [117, "u"], [118, "v"], [119, "w"], [120, "x"], [121, "y"], [122, "z"], [123, "{"], [124, "|"], [125, "}"], [126, "~"], [127, " "], [128, "€"], [129, " "], [130, "‚"], [131, "ƒ"], [132, "„"], [133, "…"], [134, "†"], [135, "‡"], [136, "ˆ"], [137, "‰"], [138, "Š"], [139, "‹"], [140, "Œ"], [141, " "], [142, "Ž"], [143, " "], [144, " "], [145, "‘"], [146, "’"], [147, "“"], [148, "”"], [149, "•"], [150, "–"], [151, "—"], [152, "˜"], [153, "™"], [154, "š"], [155, "›"], [156, "œ"], [157, " "], [158, "ž"], [159, "Ÿ"], [160, " "], [161, "¡"], [162, "¢"], [163, "£"], [164, "¤"], [165, "¥"], [166, "¦"], [167, "§"], [168, "¨"], [169, "©"], [170, "ª"], [171, "«"], [172, "¬"], [173, "1"], [174, "®"], [175, "¯"], [176, "°"], [177, "±"], [178, "²"], [179, "³"], [180, "´"], [181, "µ"], [182, "¶"], [183, "·"], [184, "¸"], [185, "¹"], [186, "º"], [187, "»"], [188, "¼"], [189, "½"], [190, "¾"], [191, "¿"], [192, "À"], [193, "Á"], [194, "Â"], [195, "Ã"], [196, "Ä"], [197, "Å"], [198, "Æ"], [199, "Ç"], [200, "È"], [201, "É"], [202, "Ê"], [203, "Ë"], [204, "Ì"], [205, "Í"], [206, "Î"], [207, "Ï"], [208, "Ð"], [209, "Ñ"], [210, "Ò"], [211, "Ó"], [212, "Ô"], [213, "Õ"], [214, "Ö"], [215, "×"], [216, "Ø"], [217, "Ù"], [218, "Ú"], [219, "Û"], [220, "Ü"], [221, "Ý"], [222, "Þ"], [223, "ß"], [224, "à"], [225, "á"], [226, "â"], [227, "ã"], [228, "ä"], [229, "å"], [230, "æ"], [231, "ç"], [232, "è"], [233, "é"], [234, "ê"], [235, "ë"], [236, "ì"], [237, "í"], [238, "î"], [239, "ï"], [240, "ð"], [241, "ñ"], [242, "ò"], [243, "ó"], [244, "ô"], [245, "õ"], [246, "ö"], [247, "÷"], [248, "ø"], [249, "ù"], [250, "ú"], [251, "û"], [252, "ü"], [253, "ý"], [254, "þ"], [255, "ÿ"]]
|
16
|
+
|
17
|
+
a.each do |i, char|
|
18
|
+
text "#{i} #{char}"
|
19
|
+
end
|
20
|
+
end
|
data/examples/m17n/sjis.rb
CHANGED
@@ -10,7 +10,8 @@
|
|
10
10
|
# font to include japanese glyphs. On 1.8.x comaptible VMs, an exception
|
11
11
|
# will be raised.
|
12
12
|
|
13
|
-
require
|
13
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
14
|
+
%w[.. example_helper]))
|
14
15
|
|
15
16
|
begin
|
16
17
|
ruby_19 do
|
data/examples/m17n/utf8.rb
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
# Shows that Prawn works out of the box with UTF-8 text, so long as you use
|
4
4
|
# a TTF file with the necessary glyphs for your content.
|
5
5
|
#
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("utf8.pdf") do
|
9
10
|
font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
10
11
|
text "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει." * 20
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
|
@@ -4,7 +4,8 @@
|
|
4
4
|
# in fonts, along with their character widths and WinAnsi codes. Be sure
|
5
5
|
# to pass these glyphs as UTF-8, and Prawn will transcode them for you.
|
6
6
|
#
|
7
|
-
require
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
%w[.. example_helper]))
|
8
9
|
|
9
10
|
FONT_SIZE = 9.5
|
10
11
|
|
data/examples/table/bill.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
+
%w[.. example_helper]))
|
5
|
+
|
6
|
+
Prawn::Document.generate("borders.pdf") do |pdf|
|
7
|
+
pdf.text "This example demonstrates alignment of the background and " +
|
8
|
+
"borders, including proper corner alignment without overlap."
|
9
|
+
pdf.move_down 20
|
10
|
+
|
11
|
+
pdf.cell :content => "all borders", :background_color => 'ff0000'
|
12
|
+
pdf.move_down 15
|
13
|
+
|
14
|
+
[:top, :bottom, :left, :right].each do |border|
|
15
|
+
y = pdf.cursor
|
16
|
+
pdf.cell :content => "no #{border} border", :background_color => 'ff0000',
|
17
|
+
:borders => ([:top, :bottom, :left, :right] - [border])
|
18
|
+
pdf.cell :content => "#{border} border 0", :background_color => 'ff0000',
|
19
|
+
:"border_#{border}_width" => 0, :at => [150, y]
|
20
|
+
pdf.cell :content => "#{border} border 2", :background_color => 'ff0000',
|
21
|
+
:"border_#{border}_width" => 2, :at => [300, y]
|
22
|
+
pdf.move_down 15
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
data/examples/table/cell.rb
CHANGED
@@ -5,8 +5,9 @@
|
|
5
5
|
# building your own table implementation from scratch or heavily modify
|
6
6
|
# the existing table system.
|
7
7
|
#
|
8
|
-
require
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
9
|
+
%w[.. example_helper]))
|
9
10
|
|
10
11
|
Prawn::Document.generate("cell.pdf") do
|
11
|
-
cell :content => "test", :padding => 10, :
|
12
|
+
cell :content => "test", :padding => 10, :font_style => :bold, :size => 7
|
12
13
|
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# Shows how to use the style() method with a block to style each cell with
|
4
4
|
# custom code.
|
5
5
|
|
6
|
-
require
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
7
|
+
%w[.. example_helper]))
|
7
8
|
|
8
9
|
Prawn::Document.generate("checkerboard.pdf") do
|
9
10
|
|
data/examples/table/header.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
require
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
+
%w[.. example_helper]))
|
4
5
|
|
5
6
|
Prawn::Document.generate("header.pdf") do
|
6
7
|
|
@@ -8,7 +9,7 @@ Prawn::Document.generate("header.pdf") do
|
|
8
9
|
data = ["Bender Bending Rodriguez", "Bender"]
|
9
10
|
|
10
11
|
table([header] + [data] * 50, :header => true) do
|
11
|
-
row(0).style(:
|
12
|
+
row(0).style(:font_style => :bold, :background_color => 'cccccc')
|
12
13
|
end
|
13
14
|
|
14
15
|
end
|