fullcirclegroup-prawn 0.2.99.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +340 -0
- data/LICENSE +56 -0
- data/README +47 -0
- data/Rakefile +76 -0
- data/data/fonts/Activa.ttf +0 -0
- data/data/fonts/Chalkboard.ttf +0 -0
- data/data/fonts/Courier-Bold.afm +342 -0
- data/data/fonts/Courier-BoldOblique.afm +342 -0
- data/data/fonts/Courier-Oblique.afm +342 -0
- data/data/fonts/Courier.afm +342 -0
- data/data/fonts/DejaVuSans.ttf +0 -0
- data/data/fonts/Dustismo_Roman.ttf +0 -0
- data/data/fonts/Helvetica-Bold.afm +2827 -0
- data/data/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/data/fonts/Helvetica-Oblique.afm +3051 -0
- data/data/fonts/Helvetica.afm +3051 -0
- data/data/fonts/MustRead.html +19 -0
- data/data/fonts/Symbol.afm +213 -0
- data/data/fonts/Times-Bold.afm +2588 -0
- data/data/fonts/Times-BoldItalic.afm +2384 -0
- data/data/fonts/Times-Italic.afm +2667 -0
- data/data/fonts/Times-Roman.afm +2419 -0
- data/data/fonts/ZapfDingbats.afm +225 -0
- data/data/fonts/comicsans.ttf +0 -0
- data/data/fonts/gkai00mp.ttf +0 -0
- data/data/images/arrow.png +0 -0
- data/data/images/arrow2.png +0 -0
- data/data/images/barcode_issue.png +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.dat +0 -0
- data/data/images/dice.png +0 -0
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.dat +0 -0
- data/data/images/page_white_text.png +0 -0
- data/data/images/pigs.jpg +0 -0
- data/data/images/rails.dat +0 -0
- data/data/images/rails.png +0 -0
- data/data/images/ruport.png +0 -0
- data/data/images/ruport_data.dat +0 -0
- data/data/images/ruport_transparent.png +0 -0
- data/data/images/ruport_type0.png +0 -0
- data/data/images/stef.jpg +0 -0
- data/data/images/web-links.dat +1 -0
- data/data/images/web-links.png +0 -0
- data/data/shift_jis_text.txt +1 -0
- data/examples/addressbook.csv +6 -0
- data/examples/alignment.rb +16 -0
- data/examples/bounding_boxes.rb +30 -0
- data/examples/canvas.rb +12 -0
- data/examples/cell.rb +38 -0
- data/examples/chinese_text_wrapping.rb +17 -0
- data/examples/currency.csv +1834 -0
- data/examples/curves.rb +10 -0
- data/examples/family_based_styling.rb +21 -0
- data/examples/fancy_table.rb +61 -0
- data/examples/flowing_text_with_header_and_footer.rb +72 -0
- data/examples/font_size.rb +27 -0
- data/examples/hexagon.rb +14 -0
- data/examples/image.rb +23 -0
- data/examples/image2.rb +13 -0
- data/examples/image_flow.rb +34 -0
- data/examples/kerning.rb +27 -0
- data/examples/lazy_bounding_boxes.rb +19 -0
- data/examples/line.rb +31 -0
- data/examples/multi_page_layout.rb +14 -0
- data/examples/page_geometry.rb +28 -0
- data/examples/png_types.rb +23 -0
- data/examples/polygons.rb +16 -0
- data/examples/position_by_baseline.rb +26 -0
- data/examples/ruport_formatter.rb +50 -0
- data/examples/ruport_helpers.rb +18 -0
- data/examples/russian_boxes.rb +34 -0
- data/examples/simple_text.rb +15 -0
- data/examples/simple_text_ttf.rb +16 -0
- data/examples/sjis.rb +21 -0
- data/examples/span.rb +27 -0
- data/examples/table.rb +47 -0
- data/examples/table_header_color.rb +16 -0
- data/examples/text_flow.rb +65 -0
- data/examples/top_and_bottom_cells.rb +40 -0
- data/examples/utf8.rb +12 -0
- data/lib/prawn.rb +67 -0
- data/lib/prawn/compatibility.rb +46 -0
- data/lib/prawn/document.rb +309 -0
- data/lib/prawn/document/bounding_box.rb +362 -0
- data/lib/prawn/document/internals.rb +113 -0
- data/lib/prawn/document/page_geometry.rb +79 -0
- data/lib/prawn/document/span.rb +47 -0
- data/lib/prawn/document/table.rb +350 -0
- data/lib/prawn/document/text.rb +196 -0
- data/lib/prawn/errors.rb +48 -0
- data/lib/prawn/font.rb +356 -0
- data/lib/prawn/font/cmap.rb +59 -0
- data/lib/prawn/font/metrics.rb +378 -0
- data/lib/prawn/font/wrapping.rb +47 -0
- data/lib/prawn/graphics.rb +252 -0
- data/lib/prawn/graphics/cell.rb +264 -0
- data/lib/prawn/graphics/color.rb +132 -0
- data/lib/prawn/images.rb +336 -0
- data/lib/prawn/images/jpg.rb +45 -0
- data/lib/prawn/images/png.rb +199 -0
- data/lib/prawn/pdf_object.rb +73 -0
- data/lib/prawn/reference.rb +56 -0
- data/spec/bounding_box_spec.rb +141 -0
- data/spec/document_spec.rb +181 -0
- data/spec/font_spec.rb +141 -0
- data/spec/graphics_spec.rb +209 -0
- data/spec/images_spec.rb +68 -0
- data/spec/jpg_spec.rb +25 -0
- data/spec/metrics_spec.rb +62 -0
- data/spec/pdf_object_spec.rb +112 -0
- data/spec/png_spec.rb +196 -0
- data/spec/reference_spec.rb +42 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/table_spec.rb +179 -0
- data/spec/text_spec.rb +135 -0
- metadata +181 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
|
4
|
+
|
|
5
|
+
describe "A Reference object" do
|
|
6
|
+
it "should produce a PDF reference on #to_s call" do
|
|
7
|
+
ref = Prawn::Reference(1,true)
|
|
8
|
+
ref.to_s.should == "1 0 R"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should allow changing generation number" do
|
|
12
|
+
ref = Prawn::Reference(1,true)
|
|
13
|
+
ref.gen = 1
|
|
14
|
+
ref.to_s.should == "1 1 R"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should generate a valid PDF object for the referenced data" do
|
|
18
|
+
ref = Prawn::Reference(2,[1,"foo"])
|
|
19
|
+
ref.object.should == "2 0 obj\n#{Prawn::PdfObject([1,"foo"])}\nendobj\n"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should automatically open a stream when #<< is used" do
|
|
23
|
+
ref = Prawn::Reference(1, :Length => 41)
|
|
24
|
+
ref << "BT\n/F1 12 Tf\n72 712 Td\n( A stream ) Tj\nET"
|
|
25
|
+
ref.object.should == "1 0 obj\n<< /Length 41\n>>\nstream"+
|
|
26
|
+
"\nBT\n/F1 12 Tf\n72 712 Td\n( A stream ) Tj\nET" +
|
|
27
|
+
"\nendstream\nendobj\n"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should compress a stream upon request" do
|
|
31
|
+
ref = Prawn::Reference(2,{})
|
|
32
|
+
ref << "Hi There " * 20
|
|
33
|
+
|
|
34
|
+
cref = Prawn::Reference(2,{})
|
|
35
|
+
cref << "Hi There " * 20
|
|
36
|
+
cref.compress_stream
|
|
37
|
+
|
|
38
|
+
assert cref.stream.size < ref.stream.size,
|
|
39
|
+
"compressed stream expected to be smaller than source but wasn't"
|
|
40
|
+
cref.data[:Filter].should == :FlateDecode
|
|
41
|
+
end
|
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
puts "Prawn specs: Running on Ruby Version: #{RUBY_VERSION}"
|
|
4
|
+
|
|
5
|
+
require "rubygems"
|
|
6
|
+
require "test/spec"
|
|
7
|
+
require "mocha"
|
|
8
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
|
9
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'vendor','pdf-inspector','lib')
|
|
10
|
+
require "prawn"
|
|
11
|
+
|
|
12
|
+
Prawn.debug = true
|
|
13
|
+
|
|
14
|
+
gem 'pdf-reader', ">=0.7.3"
|
|
15
|
+
require "pdf/reader"
|
|
16
|
+
require "pdf/inspector"
|
|
17
|
+
|
|
18
|
+
def create_pdf(klass=Prawn::Document)
|
|
19
|
+
@pdf = klass.new(:left_margin => 0,
|
|
20
|
+
:right_margin => 0,
|
|
21
|
+
:top_margin => 0,
|
|
22
|
+
:bottom_margin => 0)
|
|
23
|
+
end
|
data/spec/table_spec.rb
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
|
4
|
+
|
|
5
|
+
describe "A table's width" do
|
|
6
|
+
it "should equal sum(col_widths)" do
|
|
7
|
+
pdf = Prawn::Document.new
|
|
8
|
+
table = Prawn::Document::Table.new( [%w[ a b c ], %w[d e f]], pdf,
|
|
9
|
+
:widths => { 0 => 50, 1 => 100, 2 => 150 })
|
|
10
|
+
|
|
11
|
+
table.width.should == 300
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should calculate unspecified column widths as "+
|
|
15
|
+
"(max(string_width).ceil + 2*horizontal_padding)" do
|
|
16
|
+
pdf = Prawn::Document.new
|
|
17
|
+
hpad, fs = 3, 12
|
|
18
|
+
columns = 2
|
|
19
|
+
table = Prawn::Document::Table.new( [%w[ foo b ], %w[d foobar]], pdf,
|
|
20
|
+
:horizontal_padding => hpad, :font_size => fs)
|
|
21
|
+
|
|
22
|
+
col0_width = pdf.font.metrics.string_width("foo",fs)
|
|
23
|
+
col1_width = pdf.font.metrics.string_width("foobar",fs)
|
|
24
|
+
|
|
25
|
+
table.width.should == col0_width.ceil + col1_width.ceil + 2*columns*hpad
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should allow mixing autocalculated and preset"+
|
|
29
|
+
"column widths within a single table" do
|
|
30
|
+
|
|
31
|
+
pdf = Prawn::Document.new
|
|
32
|
+
hpad, fs = 10, 6
|
|
33
|
+
stretchy_columns = 2
|
|
34
|
+
|
|
35
|
+
col0_width = 50
|
|
36
|
+
col1_width = pdf.font.metrics.string_width("foo",fs)
|
|
37
|
+
col2_width = pdf.font.metrics.string_width("foobar",fs)
|
|
38
|
+
col3_width = 150
|
|
39
|
+
|
|
40
|
+
table = Prawn::Document::Table.new( [%w[snake foo b apple],
|
|
41
|
+
%w[kitten d foobar banana]], pdf,
|
|
42
|
+
:horizontal_padding => hpad, :font_size => fs,
|
|
43
|
+
:widths => { 0 => col0_width, 3 => col3_width } )
|
|
44
|
+
|
|
45
|
+
table.width.should == col1_width.ceil + col2_width.ceil +
|
|
46
|
+
2*stretchy_columns*hpad +
|
|
47
|
+
col0_width.ceil + col3_width.ceil
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "A table's height" do
|
|
54
|
+
|
|
55
|
+
before :each do
|
|
56
|
+
data = [["foo"],["bar"],["baaaz"]]
|
|
57
|
+
pdf = Prawn::Document.new
|
|
58
|
+
@num_rows = data.length
|
|
59
|
+
|
|
60
|
+
@vpad = 4
|
|
61
|
+
origin = pdf.y
|
|
62
|
+
pdf.table data, :vertical_padding => @vpad
|
|
63
|
+
|
|
64
|
+
@table_height = origin - pdf.y
|
|
65
|
+
|
|
66
|
+
@font_height = pdf.font.height
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should have a height of n rows" do
|
|
70
|
+
@table_height.should.be.close(
|
|
71
|
+
@num_rows*@font_height + 2*@vpad*@num_rows, 0.001 )
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "A table's content" do
|
|
77
|
+
|
|
78
|
+
it "should not cause an error if rendering the very first row causes a page break" do
|
|
79
|
+
Prawn::Document.new( :page_layout => :portrait ) do
|
|
80
|
+
arr = Array(1..5).collect{|i| ["cell #{i}"] }
|
|
81
|
+
|
|
82
|
+
move_down( y - (bounds.absolute_bottom + 3) )
|
|
83
|
+
|
|
84
|
+
lambda {
|
|
85
|
+
table( arr,
|
|
86
|
+
:font_size => 9,
|
|
87
|
+
:horizontal_padding => 3,
|
|
88
|
+
:vertical_padding => 3,
|
|
89
|
+
:border_width => 0.05,
|
|
90
|
+
:border_style => :none,
|
|
91
|
+
:row_colors => %w{ffffff eeeeee},
|
|
92
|
+
:widths => {0 =>110},
|
|
93
|
+
:position => :left,
|
|
94
|
+
:headers => ["exploding header"],
|
|
95
|
+
:align => :left,
|
|
96
|
+
:align_headers => :center)
|
|
97
|
+
}.should.not.raise
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should output content cell by cell, row by row" do
|
|
102
|
+
data = [["foo","bar"],["baz","bang"]]
|
|
103
|
+
@pdf = Prawn::Document.new
|
|
104
|
+
@pdf.table(data)
|
|
105
|
+
output = PDF::Inspector::Text.analyze(@pdf.render)
|
|
106
|
+
output.strings.should == data.flatten
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "should add headers to output when specified" do
|
|
110
|
+
data = [["foo","bar"],["baz","bang"]]
|
|
111
|
+
headers = %w[a b]
|
|
112
|
+
@pdf = Prawn::Document.new
|
|
113
|
+
@pdf.table(data, :headers => headers)
|
|
114
|
+
output = PDF::Inspector::Text.analyze(@pdf.render)
|
|
115
|
+
output.strings.should == headers + data.flatten
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should repeat headers across pages" do
|
|
119
|
+
data = [["foo","bar"]]*30
|
|
120
|
+
headers = ["baz","foobar"]
|
|
121
|
+
@pdf = Prawn::Document.new
|
|
122
|
+
@pdf.table(data, :headers => headers)
|
|
123
|
+
output = PDF::Inspector::Text.analyze(@pdf.render)
|
|
124
|
+
output.strings.should == headers + data.flatten[0..-3] + headers +
|
|
125
|
+
data.flatten[-2..-1]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "should allow empty fields" do
|
|
129
|
+
lambda {
|
|
130
|
+
data = [["foo","bar"],["baz",""]]
|
|
131
|
+
@pdf = Prawn::Document.new
|
|
132
|
+
@pdf.table(data)
|
|
133
|
+
}.should.not.raise
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "should paginate for large tables" do
|
|
137
|
+
# 30 rows fit on the table with default setting, 31 exceed.
|
|
138
|
+
data = [["foo"]] * 31
|
|
139
|
+
pdf = Prawn::Document.new
|
|
140
|
+
|
|
141
|
+
pdf.table data
|
|
142
|
+
pdf.page_count.should == 2
|
|
143
|
+
|
|
144
|
+
pdf.table data
|
|
145
|
+
pdf.page_count.should == 3
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "An invalid table" do
|
|
151
|
+
|
|
152
|
+
before(:each) do
|
|
153
|
+
@pdf = Prawn::Document.new
|
|
154
|
+
@bad_data = ["Single Nested Array"]
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "should raise error when invalid table data is given" do
|
|
158
|
+
assert_raises(Prawn::Errors::InvalidTableData) do
|
|
159
|
+
@pdf.table(@bad_data)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "should raise an EmptyTableError with empty table data" do
|
|
164
|
+
lambda {
|
|
165
|
+
data = []
|
|
166
|
+
@pdf = Prawn::Document.new
|
|
167
|
+
@pdf.table(data)
|
|
168
|
+
}.should.raise( Prawn::Errors::EmptyTable )
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "should raise an EmptyTableError with nil table data" do
|
|
172
|
+
lambda {
|
|
173
|
+
data = nil
|
|
174
|
+
@pdf = Prawn::Document.new
|
|
175
|
+
@pdf.table(data)
|
|
176
|
+
}.should.raise( Prawn::Errors::EmptyTable )
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
end
|
data/spec/text_spec.rb
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
|
4
|
+
|
|
5
|
+
describe "when drawing text" do
|
|
6
|
+
|
|
7
|
+
before(:each) { create_pdf }
|
|
8
|
+
|
|
9
|
+
it "should advance down the document based on font_height" do
|
|
10
|
+
position = @pdf.y
|
|
11
|
+
@pdf.text "Foo"
|
|
12
|
+
|
|
13
|
+
@pdf.y.should.be.close(position - @pdf.font.height, 0.0001)
|
|
14
|
+
|
|
15
|
+
position = @pdf.y
|
|
16
|
+
@pdf.text "Foo\nBar\nBaz"
|
|
17
|
+
@pdf.y.should.be.close(position - 3*@pdf.font.height, 0.0001)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should default to 12 point helvetica" do
|
|
21
|
+
@pdf.text "Blah", :at => [100,100]
|
|
22
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
23
|
+
text.font_settings[0][:name].should == :Helvetica
|
|
24
|
+
text.font_settings[0][:size].should == 12
|
|
25
|
+
text.strings.first.should == "Blah"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should allow setting font size" do
|
|
29
|
+
@pdf.text "Blah", :at => [100,100], :size => 16
|
|
30
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
31
|
+
text.font_settings[0][:size].should == 16
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should allow setting a default font size" do
|
|
35
|
+
@pdf.font.size = 16
|
|
36
|
+
@pdf.text "Blah"
|
|
37
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
38
|
+
text.font_settings[0][:size].should == 16
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should allow overriding default font for a single instance" do
|
|
42
|
+
@pdf.font.size = 16
|
|
43
|
+
|
|
44
|
+
@pdf.text "Blah", :size => 11
|
|
45
|
+
@pdf.text "Blaz"
|
|
46
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
47
|
+
text.font_settings[0][:size].should == 11
|
|
48
|
+
text.font_settings[1][:size].should == 16
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should allow setting a font size transaction with a block" do
|
|
52
|
+
@pdf.font.size 16 do
|
|
53
|
+
@pdf.text 'Blah'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
@pdf.text 'blah'
|
|
57
|
+
|
|
58
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
59
|
+
text.font_settings[0][:size].should == 16
|
|
60
|
+
text.font_settings[1][:size].should == 12
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should allow manual setting the font size " +
|
|
64
|
+
"when in a font size block" do
|
|
65
|
+
@pdf.font.size(16) do
|
|
66
|
+
@pdf.text 'Foo'
|
|
67
|
+
@pdf.text 'Blah', :size => 11
|
|
68
|
+
@pdf.text 'Blaz'
|
|
69
|
+
end
|
|
70
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
71
|
+
text.font_settings[0][:size].should == 16
|
|
72
|
+
text.font_settings[1][:size].should == 11
|
|
73
|
+
text.font_settings[2][:size].should == 16
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should allow registering of built-in font_settings on the fly" do
|
|
77
|
+
@pdf.font "Times-Roman"
|
|
78
|
+
@pdf.text "Blah", :at => [100,100]
|
|
79
|
+
@pdf.font "Courier"
|
|
80
|
+
@pdf.text "Blaz", :at => [150,150]
|
|
81
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
82
|
+
text.font_settings[0][:name].should == :"Times-Roman"
|
|
83
|
+
text.font_settings[1][:name].should == :Courier
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should utilise the same default font across multiple pages" do
|
|
87
|
+
@pdf.text "Blah", :at => [100,100]
|
|
88
|
+
@pdf.start_new_page
|
|
89
|
+
@pdf.text "Blaz", :at => [150,150]
|
|
90
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
91
|
+
|
|
92
|
+
text.font_settings.size.should == 2
|
|
93
|
+
text.font_settings[0][:name].should == :Helvetica
|
|
94
|
+
text.font_settings[1][:name].should == :Helvetica
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should raise an exception when an unknown font is used" do
|
|
98
|
+
lambda { @pdf.font "Pao bu" }.should.raise(Prawn::Errors::UnknownFont)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should correctly render a utf-8 string when using a built-in font" do
|
|
102
|
+
str = "©" # copyright symbol
|
|
103
|
+
@pdf.text str
|
|
104
|
+
|
|
105
|
+
# grab the text from the rendered PDF and ensure it matches
|
|
106
|
+
text = PDF::Inspector::Text.analyze(@pdf.render)
|
|
107
|
+
text.strings.first.should == str
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
if "spec".respond_to?(:encode!)
|
|
111
|
+
# Handle non utf-8 string encodings in a sane way on M17N aware VMs
|
|
112
|
+
it "should raise an exception when a utf-8 incompatible string is rendered" do
|
|
113
|
+
str = "Blah \xDD"
|
|
114
|
+
str.force_encoding("ASCII-8BIT")
|
|
115
|
+
lambda { @pdf.text str }.should.raise(Prawn::Errors::IncompatibleStringEncoding)
|
|
116
|
+
end
|
|
117
|
+
it "should not raise an exception when a shift-jis string is rendered" do
|
|
118
|
+
datafile = "#{Prawn::BASEDIR}/data/shift_jis_text.txt"
|
|
119
|
+
sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
|
|
120
|
+
@pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
|
|
121
|
+
lambda { @pdf.text sjis_str }.should.not.raise(Prawn::Errors::IncompatibleStringEncoding)
|
|
122
|
+
end
|
|
123
|
+
else
|
|
124
|
+
# Handle non utf-8 string encodings in a sane way on non-M17N aware VMs
|
|
125
|
+
it "should raise an exception when a corrupt utf-8 string is rendered" do
|
|
126
|
+
str = "Blah \xDD"
|
|
127
|
+
lambda { @pdf.text str }.should.raise(Prawn::Errors::IncompatibleStringEncoding)
|
|
128
|
+
end
|
|
129
|
+
it "should raise an exception when a shift-jis string is rendered" do
|
|
130
|
+
sjis_str = File.read("#{Prawn::BASEDIR}/data/shift_jis_text.txt")
|
|
131
|
+
lambda { @pdf.text sjis_str }.should.raise(Prawn::Errors::IncompatibleStringEncoding)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fullcirclegroup-prawn
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.99.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Gregory Brown
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-10-27 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Prawn is a fast, tiny, and nimble PDF generator for Ruby.
|
|
17
|
+
email: gregory.t.brown@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- README
|
|
24
|
+
- LICENSE
|
|
25
|
+
- COPYING
|
|
26
|
+
files:
|
|
27
|
+
- examples/addressbook.csv
|
|
28
|
+
- examples/alignment.rb
|
|
29
|
+
- examples/bounding_boxes.rb
|
|
30
|
+
- examples/canvas.rb
|
|
31
|
+
- examples/cell.rb
|
|
32
|
+
- examples/chinese_text_wrapping.rb
|
|
33
|
+
- examples/currency.csv
|
|
34
|
+
- examples/curves.rb
|
|
35
|
+
- examples/family_based_styling.rb
|
|
36
|
+
- examples/fancy_table.rb
|
|
37
|
+
- examples/flowing_text_with_header_and_footer.rb
|
|
38
|
+
- examples/hexagon.rb
|
|
39
|
+
- examples/image.rb
|
|
40
|
+
- examples/image2.rb
|
|
41
|
+
- examples/image_flow.rb
|
|
42
|
+
- examples/kerning.rb
|
|
43
|
+
- examples/lazy_bounding_boxes.rb
|
|
44
|
+
- examples/line.rb
|
|
45
|
+
- examples/multi_page_layout.rb
|
|
46
|
+
- examples/page_geometry.rb
|
|
47
|
+
- examples/png_types.rb
|
|
48
|
+
- examples/polygons.rb
|
|
49
|
+
- examples/position_by_baseline.rb
|
|
50
|
+
- examples/ruport_formatter.rb
|
|
51
|
+
- examples/ruport_helpers.rb
|
|
52
|
+
- examples/russian_boxes.rb
|
|
53
|
+
- examples/simple_text.rb
|
|
54
|
+
- examples/simple_text_ttf.rb
|
|
55
|
+
- examples/sjis.rb
|
|
56
|
+
- examples/table.rb
|
|
57
|
+
- examples/table_header_color.rb
|
|
58
|
+
- examples/text_flow.rb
|
|
59
|
+
- examples/top_and_bottom_cells.rb
|
|
60
|
+
- examples/utf8.rb
|
|
61
|
+
- examples/font_size.rb
|
|
62
|
+
- examples/span.rb
|
|
63
|
+
- lib/prawn.rb
|
|
64
|
+
- lib/prawn
|
|
65
|
+
- lib/prawn/compatibility.rb
|
|
66
|
+
- lib/prawn/document.rb
|
|
67
|
+
- lib/prawn/document
|
|
68
|
+
- lib/prawn/document/internals.rb
|
|
69
|
+
- lib/prawn/document/page_geometry.rb
|
|
70
|
+
- lib/prawn/document/span.rb
|
|
71
|
+
- lib/prawn/document/table.rb
|
|
72
|
+
- lib/prawn/document/text.rb
|
|
73
|
+
- lib/prawn/document/bounding_box.rb
|
|
74
|
+
- lib/prawn/errors.rb
|
|
75
|
+
- lib/prawn/font.rb
|
|
76
|
+
- lib/prawn/font
|
|
77
|
+
- lib/prawn/font/cmap.rb
|
|
78
|
+
- lib/prawn/font/metrics.rb
|
|
79
|
+
- lib/prawn/font/wrapping.rb
|
|
80
|
+
- lib/prawn/graphics.rb
|
|
81
|
+
- lib/prawn/graphics
|
|
82
|
+
- lib/prawn/graphics/cell.rb
|
|
83
|
+
- lib/prawn/graphics/color.rb
|
|
84
|
+
- lib/prawn/images.rb
|
|
85
|
+
- lib/prawn/images
|
|
86
|
+
- lib/prawn/images/jpg.rb
|
|
87
|
+
- lib/prawn/images/png.rb
|
|
88
|
+
- lib/prawn/pdf_object.rb
|
|
89
|
+
- lib/prawn/reference.rb
|
|
90
|
+
- spec/document_spec.rb
|
|
91
|
+
- spec/font_spec.rb
|
|
92
|
+
- spec/graphics_spec.rb
|
|
93
|
+
- spec/images_spec.rb
|
|
94
|
+
- spec/jpg_spec.rb
|
|
95
|
+
- spec/metrics_spec.rb
|
|
96
|
+
- spec/pdf_object_spec.rb
|
|
97
|
+
- spec/png_spec.rb
|
|
98
|
+
- spec/reference_spec.rb
|
|
99
|
+
- spec/spec_helper.rb
|
|
100
|
+
- spec/table_spec.rb
|
|
101
|
+
- spec/text_spec.rb
|
|
102
|
+
- spec/bounding_box_spec.rb
|
|
103
|
+
- data/fonts
|
|
104
|
+
- data/fonts/Activa.ttf
|
|
105
|
+
- data/fonts/Chalkboard.ttf
|
|
106
|
+
- data/fonts/Courier-Bold.afm
|
|
107
|
+
- data/fonts/Courier-BoldOblique.afm
|
|
108
|
+
- data/fonts/Courier-Oblique.afm
|
|
109
|
+
- data/fonts/Courier.afm
|
|
110
|
+
- data/fonts/DejaVuSans.ttf
|
|
111
|
+
- data/fonts/Dustismo_Roman.ttf
|
|
112
|
+
- data/fonts/Helvetica-Bold.afm
|
|
113
|
+
- data/fonts/Helvetica-BoldOblique.afm
|
|
114
|
+
- data/fonts/Helvetica-Oblique.afm
|
|
115
|
+
- data/fonts/Helvetica.afm
|
|
116
|
+
- data/fonts/MustRead.html
|
|
117
|
+
- data/fonts/Symbol.afm
|
|
118
|
+
- data/fonts/Times-Bold.afm
|
|
119
|
+
- data/fonts/Times-BoldItalic.afm
|
|
120
|
+
- data/fonts/Times-Italic.afm
|
|
121
|
+
- data/fonts/Times-Roman.afm
|
|
122
|
+
- data/fonts/ZapfDingbats.afm
|
|
123
|
+
- data/fonts/comicsans.ttf
|
|
124
|
+
- data/fonts/gkai00mp.ttf
|
|
125
|
+
- data/images
|
|
126
|
+
- data/images/arrow.png
|
|
127
|
+
- data/images/arrow2.png
|
|
128
|
+
- data/images/barcode_issue.png
|
|
129
|
+
- data/images/dice.alpha
|
|
130
|
+
- data/images/dice.dat
|
|
131
|
+
- data/images/dice.png
|
|
132
|
+
- data/images/page_white_text.alpha
|
|
133
|
+
- data/images/page_white_text.dat
|
|
134
|
+
- data/images/page_white_text.png
|
|
135
|
+
- data/images/pigs.jpg
|
|
136
|
+
- data/images/rails.dat
|
|
137
|
+
- data/images/rails.png
|
|
138
|
+
- data/images/ruport.png
|
|
139
|
+
- data/images/ruport_data.dat
|
|
140
|
+
- data/images/ruport_transparent.png
|
|
141
|
+
- data/images/ruport_type0.png
|
|
142
|
+
- data/images/stef.jpg
|
|
143
|
+
- data/images/web-links.dat
|
|
144
|
+
- data/images/web-links.png
|
|
145
|
+
- data/shift_jis_text.txt
|
|
146
|
+
- Rakefile
|
|
147
|
+
- README
|
|
148
|
+
- LICENSE
|
|
149
|
+
- COPYING
|
|
150
|
+
has_rdoc: true
|
|
151
|
+
homepage: http://prawn.majesticseacreature.com
|
|
152
|
+
post_install_message:
|
|
153
|
+
rdoc_options:
|
|
154
|
+
- --title
|
|
155
|
+
- Prawn Documentation
|
|
156
|
+
- --main
|
|
157
|
+
- README
|
|
158
|
+
- -q
|
|
159
|
+
require_paths:
|
|
160
|
+
- lib
|
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - ">="
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: "0"
|
|
166
|
+
version:
|
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
|
+
requirements:
|
|
169
|
+
- - ">="
|
|
170
|
+
- !ruby/object:Gem::Version
|
|
171
|
+
version: "0"
|
|
172
|
+
version:
|
|
173
|
+
requirements: []
|
|
174
|
+
|
|
175
|
+
rubyforge_project:
|
|
176
|
+
rubygems_version: 1.2.0
|
|
177
|
+
signing_key:
|
|
178
|
+
specification_version: 2
|
|
179
|
+
summary: A fast and nimble PDF generator for Ruby
|
|
180
|
+
test_files: []
|
|
181
|
+
|