rbpdf 1.20.0 → 1.21.0
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.
- checksums.yaml +5 -5
- data/CHANGELOG +18 -0
- data/README.md +11 -1
- data/lib/rbpdf/version.rb +2 -2
- data/lib/rbpdf.rb +69 -46
- data/lib/unicode_data.rb +29 -0
- data/rbpdf.gemspec +8 -20
- metadata +28 -101
- data/test/err_font1.rb +0 -7
- data/test/err_font2.rb +0 -8
- data/test/input.jpg +0 -0
- data/test/json: +0 -0
- data/test/logo_rbpdf_8bit .png +0 -0
- data/test/logo_rbpdf_8bit+ .png +0 -0
- data/test/logo_rbpdf_8bit.gif +0 -0
- data/test/logo_rbpdf_8bit.jpg +0 -0
- data/test/logo_rbpdf_8bit.png +0 -0
- data/test/logo_rbpdf_8bit_alpha.gif +0 -0
- data/test/logo_rbpdf_mono_gray.jpg +0 -0
- data/test/logo_rbpdf_mono_gray.png +0 -0
- data/test/logo_rbpdf_mono_rgb.jpg +0 -0
- data/test/logo_rbpdf_mono_rgb.png +0 -0
- data/test/output.png +0 -0
- data/test/png_test_alpha.png +0 -0
- data/test/png_test_msk_alpha.png +0 -0
- data/test/png_test_non_alpha.png +0 -0
- data/test/rbpdf_bidi_test.rb +0 -453
- data/test/rbpdf_bookmark_test.rb +0 -66
- data/test/rbpdf_cell_test.rb +0 -231
- data/test/rbpdf_content_test.rb +0 -213
- data/test/rbpdf_css_test.rb +0 -640
- data/test/rbpdf_dom_test.rb +0 -272
- data/test/rbpdf_examples_test.rb +0 -83
- data/test/rbpdf_font_func_test.rb +0 -45
- data/test/rbpdf_font_style_test.rb +0 -37
- data/test/rbpdf_font_test.rb +0 -308
- data/test/rbpdf_format_test.rb +0 -30
- data/test/rbpdf_func_test.rb +0 -139
- data/test/rbpdf_html_anchor_test.rb +0 -105
- data/test/rbpdf_html_func_test.rb +0 -170
- data/test/rbpdf_html_test.rb +0 -658
- data/test/rbpdf_htmlcell_test.rb +0 -60
- data/test/rbpdf_http_test.rb +0 -76
- data/test/rbpdf_image_rmagick_test.rb +0 -170
- data/test/rbpdf_image_test.rb +0 -174
- data/test/rbpdf_test.rb +0 -375
- data/test/rbpdf_transaction_test.rb +0 -203
- data/test/rbpdf_viewerpreferences_test.rb +0 -41
- data/test/rbpdf_write_test.rb +0 -229
- data/test/test.rb +0 -22
- data/test/test_helper.rb +0 -9
data/test/rbpdf_dom_test.rb
DELETED
@@ -1,272 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011-2017 NAITOH Jun
|
2
|
-
# Released under the MIT license
|
3
|
-
# http://www.opensource.org/licenses/MIT
|
4
|
-
|
5
|
-
require 'test_helper'
|
6
|
-
|
7
|
-
class RbpdfTest < Test::Unit::TestCase
|
8
|
-
class MYPDF < RBPDF
|
9
|
-
def get_temp_rtl
|
10
|
-
@tmprtl
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
htmls = {
|
15
|
-
'Simple Text' => {:html => 'abc', :length => 2,
|
16
|
-
:params => [{:parent => 0, :tag => false}, # parent -> Root
|
17
|
-
{:parent => 0, :tag => false, :value => 'abc', :elkey => 0, :block => false}]},
|
18
|
-
'Back Slash Text' => {:html => 'a\\bc', :length => 2,
|
19
|
-
:params => [{:parent => 0, :tag => false}, # parent -> Root
|
20
|
-
{:parent => 0, :tag => false, :value => 'a\\bc', :elkey => 0, :block => false}]},
|
21
|
-
'Simple Tag' => {:html => '<b>abc</b>', :length => 4,
|
22
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
23
|
-
{:parent => 0, :tag => true, :value => 'b', :elkey => 0, :opening => true, :attribute => {}},
|
24
|
-
{:parent => 1, :tag => false, :value => 'abc', :elkey => 1, :block => false}, # parent -> open tag key
|
25
|
-
{:parent => 1, :tag => true, :value => 'b', :elkey => 2, :opening => false}]}, # parent -> open tag key
|
26
|
-
'pre Tag' => {:html => "<pre>abc</pre>", :length => 4, # See. 'Dom pre tag test'
|
27
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
28
|
-
{:parent => 0, :tag => true, :value => 'pre', :elkey => 0, :opening => true, :attribute => {}},
|
29
|
-
{:parent => 1, :tag => false, :value => 'abc', :elkey => 1, :block => false}, # parent -> open tag key
|
30
|
-
{:parent => 1, :tag => true, :value => 'pre', :elkey => 2, :opening => false}]}, # parent -> open tag key
|
31
|
-
'pre code Tag' => {:html => '<pre><code class="ruby">abc</code></pre>', :length => 4, # See. 'Dom pre tag test (code)'
|
32
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
33
|
-
{:parent => 0, :tag => true, :value => 'pre', :elkey => 0, :opening => true, :attribute => {}},
|
34
|
-
{:parent => 1, :tag => false, :value => 'abc', :elkey => 1, :block => false}, # parent -> open tag key
|
35
|
-
{:parent => 1, :tag => true, :value => 'pre', :elkey => 2, :opening => false}]}, # parent -> open tag key
|
36
|
-
'pre code span Tag' => {:html => '<pre><code class="ruby syntaxhl"><span class="CodeRay">abc</span></code></pre>', :length => 6, # See. 'Dom pre tag test (code span)'
|
37
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
38
|
-
{:parent => 0, :tag => true, :value => 'pre', :elkey => 0, :opening => true, :attribute => {}},
|
39
|
-
{:parent => 1, :tag => true, :value => 'span', :elkey => 1, :opening => true},
|
40
|
-
{:parent => 2, :tag => false, :value => 'abc', :elkey => 2, :block => false}, # parent -> open tag key
|
41
|
-
{:parent => 2, :tag => true, :value => 'span', :elkey => 3, :opening => false}, # parent -> open tag key
|
42
|
-
{:parent => 1, :tag => true, :value => 'pre', :elkey => 4, :opening => false}]}, # parent -> open tag key
|
43
|
-
'Error Tag (doble colse tag)' => {:html => '</ul></div>',
|
44
|
-
:validated_length => 1, # for Rails 4.2 later (no use Rails 3.x/4.0/4.1)
|
45
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
46
|
-
{:parent => 0, :tag => true, :value => 'ul', :elkey => 0, :opening => false}, # parent -> Root key
|
47
|
-
{:parent => 0, :tag => true, :value => 'div', :elkey => 1, :opening => false}]}, # parent -> Root key
|
48
|
-
'Attribute' => {:html => '<p style="text-align:justify">abc</p>', :length => 4,
|
49
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
50
|
-
{:parent => 0, :tag => true, :value => 'p', :elkey => 0, :opening => true, :align => 'J', :attribute => {:style => 'text-align:justify;'}}]},
|
51
|
-
'Table border' => {:html => '<table border="1"><tr><td>abc</td></tr></table>', :length => 9,
|
52
|
-
# -> '<table border="1"><tr><td>abc<marker style="font-size:0"/></td></tr></table>' ## added marker tag (by getHtmlDomArray()) ##
|
53
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
54
|
-
{:parent => 0, :tag => true, :value => 'table', :elkey => 0, :opening => true, :attribute => {:border => 1}},
|
55
|
-
{},
|
56
|
-
{},
|
57
|
-
{},
|
58
|
-
# marker tag (by getHtmlDomArray())
|
59
|
-
{:parent => 3, :tag => true, :value => 'marker', :elkey => 4, :opening => true, :attribute => {:style => 'font-size:0'}}]},
|
60
|
-
'Table td Width' => {:html => '<table><tr><td width="10">abc</td></tr></table>', :length => 9,
|
61
|
-
# -> '<table><tr><td width="10">abc<marker style="font-size:0"/></td></tr></table>' ## added marker tag (by getHtmlDomArray()) ##
|
62
|
-
:params => [{},
|
63
|
-
{},
|
64
|
-
{},
|
65
|
-
{:parent => 2, :tag => true, :value => 'td', :elkey => 2, :opening => true, :width => '10'}]},
|
66
|
-
'Dom open angled bracket "<"' => {:html => "<p>AAA '<'-BBB << <<< '</' '<//' '<///' CCC.</p>", :length => 4,
|
67
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
68
|
-
{:parent => 0, :tag => true, :value => 'p', :elkey => 0, :opening => true, :attribute => {}},
|
69
|
-
{:parent => 1, :tag => false, :value => "AAA '<'-BBB << <<< '</' '<//' '<///' CCC.", :elkey => 1},
|
70
|
-
{:parent => 1, :tag => true, :value => 'p', :elkey => 2, :opening => false}]},
|
71
|
-
'Dom self close tag' => {:html => '<b>ab<br>c</b>', :length => 6, # See. 'Dom self close tag test (Simple Tag)'
|
72
|
-
:params => [{:parent => 0, :tag => false, :attribute => {}}, # parent -> Root
|
73
|
-
{:parent => 0, :tag => true, :value => 'b', :elkey => 0, :opening => true, :attribute => {}}, # <b>
|
74
|
-
{:parent => 1, :tag => false, :value => 'ab', :elkey => 1, :block => false}, # ab
|
75
|
-
{:parent => 1, :tag => true, :value => 'br', :elkey => 2, :opening => true, :attribute => {}}, # <br>
|
76
|
-
{:parent => 1, :tag => false, :value => 'c', :elkey => 3, :block => false}, # c
|
77
|
-
{:parent => 1, :tag => true, :value => 'b', :elkey => 4, :opening => false}]}, # </b>
|
78
|
-
}
|
79
|
-
|
80
|
-
data(htmls)
|
81
|
-
test "Dom Basic test" do |data|
|
82
|
-
pdf = RBPDF.new
|
83
|
-
dom = pdf.send(:getHtmlDomArray, data[:html])
|
84
|
-
assert_equal data[:length], dom.length if data[:length]
|
85
|
-
data[:params].each_with_index {|param, i|
|
86
|
-
# validated length check (for Rails 4.2 later)
|
87
|
-
if dom[i].nil? and i >= data[:validated_length]
|
88
|
-
break
|
89
|
-
end
|
90
|
-
|
91
|
-
param.each {|key, val|
|
92
|
-
if (key == :attribute) and !val.empty?
|
93
|
-
val.each {|k, v|
|
94
|
-
if (k == :style) and !v.empty?
|
95
|
-
assert_equal("dom[#{i}][attribute]: #{k} => #{v}", "dom[#{i}][attribute]: #{k} => #{dom[i][key.to_s][k.to_s].gsub(' ', '')}")
|
96
|
-
else
|
97
|
-
assert_equal("dom[#{i}][attribute]: #{k} => #{v}", "dom[#{i}][attribute]: #{k} => #{dom[i][key.to_s][k.to_s]}")
|
98
|
-
end
|
99
|
-
}
|
100
|
-
else
|
101
|
-
assert_equal("dom[#{i}]: #{key} => #{val}", "dom[#{i}]: #{key} => #{dom[i][key.to_s]}")
|
102
|
-
end
|
103
|
-
}
|
104
|
-
}
|
105
|
-
end
|
106
|
-
|
107
|
-
test "Dom pre tag test" do
|
108
|
-
pdf = RBPDF.new
|
109
|
-
|
110
|
-
# No Text
|
111
|
-
dom = pdf.send(:getHtmlDomArray, "<pre></pre>")
|
112
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>\n</pre>")
|
113
|
-
assert_equal dom, dom2
|
114
|
-
|
115
|
-
# Simple Tag
|
116
|
-
dom = pdf.send(:getHtmlDomArray, "<pre>abc</pre>")
|
117
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>\nabc\n</pre>")
|
118
|
-
assert_equal dom, dom2
|
119
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>\nabc</pre>")
|
120
|
-
assert_equal dom, dom2
|
121
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>abc\n</pre>")
|
122
|
-
assert_equal dom, dom2
|
123
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>abc<br /></pre>")
|
124
|
-
assert_equal dom, dom2
|
125
|
-
|
126
|
-
# with line feed
|
127
|
-
dom = pdf.send(:getHtmlDomArray, "<pre>abc\ndef</pre>")
|
128
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>\nabc\ndef\n</pre>")
|
129
|
-
assert_equal dom, dom2
|
130
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>\nabc\ndef</pre>")
|
131
|
-
assert_equal dom, dom2
|
132
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre>abc\ndef\n</pre>")
|
133
|
-
assert_equal dom, dom2
|
134
|
-
|
135
|
-
# code Tag
|
136
|
-
dom = pdf.send(:getHtmlDomArray, '<pre><code class="ruby">abc</code></pre>')
|
137
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby\">\nabc\n</code></pre>")
|
138
|
-
assert_equal dom, dom2
|
139
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby\">\nabc</code></pre>")
|
140
|
-
assert_equal dom, dom2
|
141
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby\">abc\n</code></pre>")
|
142
|
-
assert_equal dom, dom2
|
143
|
-
|
144
|
-
# code span Tag
|
145
|
-
dom = pdf.send(:getHtmlDomArray, '<pre><code class="ruby syntaxhl"><span class="CodeRay">abc</span></code></pre>')
|
146
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby syntaxhl\"><span class=\"CodeRay\">\nabc\n</span></code></pre>")
|
147
|
-
assert_equal dom, dom2
|
148
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby syntaxhl\"><span class=\"CodeRay\">\nabc</span></code></pre>")
|
149
|
-
assert_equal dom, dom2
|
150
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby syntaxhl\"><span class=\"CodeRay\">abc\n</span></code></pre>")
|
151
|
-
assert_equal dom, dom2
|
152
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby syntaxhl\"><span class=\"CodeRay\">abc</span>\n</code></pre>")
|
153
|
-
assert_equal dom, dom2
|
154
|
-
dom2 = pdf.send(:getHtmlDomArray, "<pre><code class=\"ruby syntaxhl\">\n<span class=\"CodeRay\">\nabc\n</span>\n</code></pre>")
|
155
|
-
assert_equal dom, dom2
|
156
|
-
end
|
157
|
-
|
158
|
-
test "Dom self close tag test" do
|
159
|
-
pdf = RBPDF.new
|
160
|
-
|
161
|
-
# Simple Tag
|
162
|
-
dom = pdf.send(:getHtmlDomArray, '<b>ab<br>c</b>')
|
163
|
-
dom2 = pdf.send(:getHtmlDomArray, '<b>ab<br/>c</b>')
|
164
|
-
assert_equal dom, dom2
|
165
|
-
|
166
|
-
htmlcontent = '<b><img src="/public/ng.png" alt="test alt attribute" width="30" height="30" border="0"/></b>'
|
167
|
-
dom1 = pdf.send(:getHtmlDomArray, htmlcontent)
|
168
|
-
htmlcontent = '<b><img src="/public/ng.png" alt="test alt attribute" width="30" height="30" border="0"></b>'
|
169
|
-
dom2 = pdf.send(:getHtmlDomArray, htmlcontent)
|
170
|
-
assert_equal dom1, dom2
|
171
|
-
|
172
|
-
dom1 = pdf.send(:getHtmlDomArray, '<b>ab<hr/>c</b>')
|
173
|
-
dom2 = pdf.send(:getHtmlDomArray, '<b>ab<hr>c</b>')
|
174
|
-
assert_equal dom1, dom2
|
175
|
-
end
|
176
|
-
|
177
|
-
test "Dom HTMLTagHandler Basic test" do
|
178
|
-
pdf = RBPDF.new
|
179
|
-
pdf.add_page
|
180
|
-
|
181
|
-
# Simple HTML
|
182
|
-
htmlcontent = '<h1>HTML Example</h1>'
|
183
|
-
dom1 = pdf.send(:getHtmlDomArray, htmlcontent)
|
184
|
-
dom2 = pdf.send(:openHTMLTagHandler, dom1, 1, false)
|
185
|
-
assert_equal dom1, dom2
|
186
|
-
end
|
187
|
-
|
188
|
-
htmls = {
|
189
|
-
'LTR' => {:lines => [{:html => '<p dir="ltr">HTML Example</p>', :length => 4,
|
190
|
-
:params => [{}, {:tag => true, :value => 'p', :opening => true, :attribute => {:dir => 'ltr'}, :temprtl => false}]},
|
191
|
-
{:html => '<p dir="rtl">HTML Example</p>', :length => 4,
|
192
|
-
:params => [{}, {:tag => true, :value => 'p', :opening => true, :attribute => {:dir => 'rtl'}, :temprtl => 'R'}]},
|
193
|
-
{:html => '<p dir="ltr">HTML Example</p>', :length => 4,
|
194
|
-
:params => [{}, {:tag => true, :value => 'p', :opening => true, :attribute => {:dir => 'ltr'}, :temprtl => false}]}
|
195
|
-
]},
|
196
|
-
'RTL' => {:rtl => true,
|
197
|
-
:lines => [{:html => '<p dir="ltr">HTML Example</p>', :length => 4,
|
198
|
-
:params => [{}, {:tag => true, :value => 'p', :opening => true, :attribute => {:dir => 'ltr'}, :temprtl => 'L'}]},
|
199
|
-
{:html => '<p dir="rtl">HTML Example</p>', :length => 4,
|
200
|
-
:params => [{}, {:tag => true, :value => 'p', :opening => true, :attribute => {:dir => 'rtl'}, :temprtl => false}]}
|
201
|
-
]},
|
202
|
-
}
|
203
|
-
|
204
|
-
data(htmls)
|
205
|
-
test "Dom HTMLTagHandler DIR test" do |data|
|
206
|
-
pdf = MYPDF.new
|
207
|
-
pdf.add_page
|
208
|
-
temprtl = pdf.get_temp_rtl
|
209
|
-
assert_equal false, temprtl
|
210
|
-
pdf.set_rtl(true) if data[:rtl]
|
211
|
-
|
212
|
-
data[:lines].each_with_index {|line, l|
|
213
|
-
dom = pdf.send(:getHtmlDomArray, line[:html])
|
214
|
-
dom = pdf.send(:openHTMLTagHandler, dom, 1, false)
|
215
|
-
|
216
|
-
assert_equal line[:length], dom.length if line[:length]
|
217
|
-
line[:params].each_with_index {|param, i|
|
218
|
-
param.each {|key, val|
|
219
|
-
if (key == :attribute) and !val.empty?
|
220
|
-
val.each {|k, v|
|
221
|
-
assert_equal("#{l}: dom[#{i}][attribute]: #{k} => #{v}", "#{l}: dom[#{i}][attribute]: #{k} => #{dom[i][key.to_s][k.to_s]}")
|
222
|
-
}
|
223
|
-
elsif (key == :temprtl)
|
224
|
-
temprtl = pdf.get_temp_rtl
|
225
|
-
assert_equal("#{l}: dom[#{i}]: temprtl => #{val}", "#{l}: dom[#{i}]: temprtl => #{temprtl.to_s}")
|
226
|
-
else
|
227
|
-
assert_equal("#{l}: dom[#{i}]: #{key} => #{val}", "#{l}: dom[#{i}]: #{key} => #{dom[i][key.to_s]}")
|
228
|
-
end
|
229
|
-
}
|
230
|
-
}
|
231
|
-
}
|
232
|
-
end
|
233
|
-
|
234
|
-
test "Dom HTMLTagHandler img y position with height attribute test" do
|
235
|
-
pdf = RBPDF.new
|
236
|
-
pdf.add_page
|
237
|
-
|
238
|
-
# Image Error HTML
|
239
|
-
htmlcontent = '<img src="/public/ng.png" alt="test alt attribute" width="30" height="30" border="0"/>'
|
240
|
-
dom1 = pdf.send(:getHtmlDomArray, htmlcontent)
|
241
|
-
#y1 = pdf.get_y
|
242
|
-
|
243
|
-
dom2 = pdf.send(:openHTMLTagHandler, dom1, 1, false)
|
244
|
-
y2 = pdf.get_y
|
245
|
-
assert_equal dom1, dom2
|
246
|
-
assert_equal pdf.get_image_rby - (12 / pdf.get_scale_factor) , y2
|
247
|
-
end
|
248
|
-
|
249
|
-
test "Dom HTMLTagHandler img y position without height attribute test" do
|
250
|
-
pdf = RBPDF.new
|
251
|
-
pdf.add_page
|
252
|
-
|
253
|
-
# Image Error HTML
|
254
|
-
htmlcontent = '<img src="/public/ng.png" alt="test alt attribute" border="0"/>'
|
255
|
-
dom1 = pdf.send(:getHtmlDomArray, htmlcontent)
|
256
|
-
y1 = pdf.get_y
|
257
|
-
|
258
|
-
dom2 = pdf.send(:openHTMLTagHandler, dom1, 1, false)
|
259
|
-
y2 = pdf.get_y
|
260
|
-
assert_equal dom1, dom2
|
261
|
-
assert_equal y1, y2
|
262
|
-
end
|
263
|
-
|
264
|
-
test "getHtmlDomArray encoding test" do
|
265
|
-
return unless 'test'.respond_to?(:force_encoding)
|
266
|
-
|
267
|
-
pdf = RBPDF.new('P', 'mm', 'A4', true, "UTF-8", true)
|
268
|
-
htmlcontent = 'test'.force_encoding('ASCII-8BIT')
|
269
|
-
pdf.send(:getHtmlDomArray, htmlcontent)
|
270
|
-
assert_equal 'ASCII-8BIT', htmlcontent.encoding.to_s
|
271
|
-
end
|
272
|
-
end
|
data/test/rbpdf_examples_test.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011-2018 NAITOH Jun
|
2
|
-
# Released under the MIT license
|
3
|
-
# http://www.opensource.org/licenses/MIT
|
4
|
-
|
5
|
-
require 'test_helper'
|
6
|
-
|
7
|
-
def logger
|
8
|
-
require 'logger'
|
9
|
-
return Logger.new(STDOUT)
|
10
|
-
end
|
11
|
-
|
12
|
-
if !defined? ApplicationController
|
13
|
-
class ApplicationController
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class RbpdfTest < Test::Unit::TestCase
|
18
|
-
htmls = {
|
19
|
-
'001 : Default Header and Footer' => '001',
|
20
|
-
'002 : Removing Header and Footer' => '002',
|
21
|
-
'003 : Custom Header and Footer' => '003',
|
22
|
-
'004 : Cell stretching' => '004',
|
23
|
-
'005 : Multicell' => '005',
|
24
|
-
'006 : write_html and RTL support' => '006',
|
25
|
-
'007 : Two independent columns with write_htmlcell()' => '007',
|
26
|
-
'008 : Include external UTF-8 text file' => '008',
|
27
|
-
'009 : Test Image' => '009',
|
28
|
-
'011 : Colored Table' => '011',
|
29
|
-
'012 : Graphic Functions' => '012',
|
30
|
-
'015 : Bookmarks (Table of Content)' => '015',
|
31
|
-
'017 : Two independent columns with MultiCell' => '017',
|
32
|
-
'018 : RTL document with Persian language' => '018',
|
33
|
-
'020 : Two columns composed by MultiCell of different' => '020',
|
34
|
-
'021 : write_html text flow' => '021',
|
35
|
-
'022 : CMYK colors' => '022',
|
36
|
-
'023 : Page Groups' => '023',
|
37
|
-
'024 : Object Visibility' => '024',
|
38
|
-
'025 : Object Transparency' => '025',
|
39
|
-
'026 : Text Rendering Modes and Text Clipping' => '026',
|
40
|
-
'028 : Changing page formats' => '028',
|
41
|
-
'029 : Set PDF viewer display preferences.' => '029',
|
42
|
-
'031 : Pie Chart' => '031',
|
43
|
-
'033 : Mixed font types' => '033',
|
44
|
-
'034 : Clipping' => '034',
|
45
|
-
'035 : Line styles with cells and multicells' => '035',
|
46
|
-
'036 : Annotations' => '036',
|
47
|
-
'038 : CID-0 CJK unembedded font' => '038',
|
48
|
-
'039 : HTML justification' => '039',
|
49
|
-
'040 : Booklet mode (double-sided pages)' => '040',
|
50
|
-
'041 : Annotation - FileAttachment' => '041',
|
51
|
-
'042 : Test Image with alpha channel' => '042',
|
52
|
-
'043 : Disk caching' => '043',
|
53
|
-
'044 : Move, copy and delete pages' => '044',
|
54
|
-
'045 : Bookmarks and Table of Content' => '045',
|
55
|
-
'047 : Transactions' => '047',
|
56
|
-
'048 : HTML tables and table headers' => '048',
|
57
|
-
# '051 : Full page background' => '051',
|
58
|
-
'055 : Display all characters available on core fonts.' => '055',
|
59
|
-
'057 : Cell vertical alignments' => '057',
|
60
|
-
'059 : Table Of Content using HTML templates.' => '059',
|
61
|
-
'060 : Advanced page settings.' => '060',
|
62
|
-
'061 : XHTML + CSS' => '061',
|
63
|
-
}
|
64
|
-
|
65
|
-
data(htmls)
|
66
|
-
test "Examples test" do |data|
|
67
|
-
$LOAD_PATH << File.join(File.dirname(File.expand_path(__FILE__)), '../example/rails/app/controllers/')
|
68
|
-
|
69
|
-
require "example#{data}_controller"
|
70
|
-
|
71
|
-
content = []
|
72
|
-
test = Object.const_get("Example#{data}Controller").new
|
73
|
-
|
74
|
-
contents = test.index
|
75
|
-
# contents = assert_nothing_raised do
|
76
|
-
# test.index
|
77
|
-
# end
|
78
|
-
contents.each_line {|line| content.push line.chomp }
|
79
|
-
|
80
|
-
assert_not_equal 0, content.length
|
81
|
-
assert_equal '%PDF-1.7', content[0]
|
82
|
-
end
|
83
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011-2017 NAITOH Jun
|
2
|
-
# Released under the MIT license
|
3
|
-
# http://www.opensource.org/licenses/MIT
|
4
|
-
|
5
|
-
require 'test_helper'
|
6
|
-
|
7
|
-
class RbpdfFontFuncTest < Test::Unit::TestCase
|
8
|
-
class MYPDF < RBPDF
|
9
|
-
def putAPXObject(w=0, h=0, stream='')
|
10
|
-
super
|
11
|
-
end
|
12
|
-
end
|
13
|
-
test "Font get_font_descent function test 1" do
|
14
|
-
pdf = RBPDF.new
|
15
|
-
fontdescent = pdf.get_font_descent('times', '', 18)
|
16
|
-
assert_in_delta 0.95, fontdescent, 0.01
|
17
|
-
end
|
18
|
-
|
19
|
-
test "Font get_font_descent function test 2" do
|
20
|
-
pdf = RBPDF.new
|
21
|
-
fontdescent = pdf.get_font_descent('freesans', '', 18)
|
22
|
-
assert_in_delta 1.91, fontdescent, 0.01
|
23
|
-
end
|
24
|
-
|
25
|
-
test "Font get_font_ascent function test 1" do
|
26
|
-
pdf = RBPDF.new
|
27
|
-
fontascent = pdf.get_font_ascent('times', '', 18)
|
28
|
-
assert_in_delta 5.39, fontascent, 0.01
|
29
|
-
end
|
30
|
-
|
31
|
-
test "Font get_font_ascent function test 2" do
|
32
|
-
pdf = RBPDF.new
|
33
|
-
fontascent = pdf.get_font_ascent('freesans', '', 18)
|
34
|
-
assert_in_delta 6.35, fontascent, 0.01
|
35
|
-
end
|
36
|
-
|
37
|
-
test "putAPXObject test" do
|
38
|
-
pdf = MYPDF.new
|
39
|
-
|
40
|
-
apxo_obj_id = pdf.putAPXObject
|
41
|
-
assert_equal 400001, apxo_obj_id
|
42
|
-
apxo_obj_id = pdf.putAPXObject
|
43
|
-
assert_equal 400002, apxo_obj_id
|
44
|
-
end
|
45
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011-2017 NAITOH Jun
|
2
|
-
# Released under the MIT license
|
3
|
-
# http://www.opensource.org/licenses/MIT
|
4
|
-
|
5
|
-
require 'test_helper'
|
6
|
-
|
7
|
-
class RbpdfFontStyleTest < Test::Unit::TestCase
|
8
|
-
class MYPDF < RBPDF
|
9
|
-
def dounderline(x, y, txt)
|
10
|
-
super
|
11
|
-
end
|
12
|
-
def dolinethrough(x, y, txt)
|
13
|
-
super
|
14
|
-
end
|
15
|
-
def dooverline(x, y, txt)
|
16
|
-
super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
test "Font dounderline function test 1" do
|
21
|
-
pdf = MYPDF.new
|
22
|
-
line = pdf.dounderline(10, 10, "test")
|
23
|
-
assert_equal '28.35 812.94 19.34 -0.60 re f', line
|
24
|
-
end
|
25
|
-
|
26
|
-
test "Font dolinethrough function test 1" do
|
27
|
-
pdf = MYPDF.new
|
28
|
-
line = pdf.dolinethrough(10, 10, "test")
|
29
|
-
assert_equal '28.35 816.94 19.34 -0.60 re f', line
|
30
|
-
end
|
31
|
-
|
32
|
-
test "Font dooverline function test 1" do
|
33
|
-
pdf = MYPDF.new
|
34
|
-
line = pdf.dooverline(10, 10, "test")
|
35
|
-
assert_equal '28.35 824.34 19.34 -0.60 re f', line
|
36
|
-
end
|
37
|
-
end
|