rbpdf 1.19.0 → 1.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +16 -0
- data/Rakefile +4 -0
- data/lib/core/rmagick.rb +1 -1
- data/lib/rbpdf.rb +82 -47
- data/lib/rbpdf/version.rb +5 -1
- data/lib/rbpdf_encode_ok.rb +15170 -0
- data/lib/rbpdf_encode_ok2.rb +15178 -0
- data/lib/unicode_data.rb +18 -1
- data/rbpdf.gemspec +21 -5
- data/test/_rbpdf_image_test.rb_ +161 -0
- data/test/err_font1.rb +4 -0
- data/test/err_font2.rb +4 -0
- data/test/logo_rbpdf_8bit .png +0 -0
- data/test/logo_rbpdf_8bit+ .png +0 -0
- data/test/logo_rbpdf_8bit_/343/201/202/343/201/204/343/201/206/343/201/210/343/201/212.png +0 -0
- data/test/rbpdf_bidi_test.rb +76 -71
- data/test/rbpdf_bookmark_test.rb +38 -28
- data/test/rbpdf_cell_test.rb +120 -40
- data/test/rbpdf_content_test.rb +62 -45
- data/test/rbpdf_css_test.rb +275 -271
- data/test/rbpdf_dom_test.rb +123 -113
- data/test/rbpdf_font_func_test.rb +6 -2
- data/test/rbpdf_font_style_test.rb +7 -3
- data/test/rbpdf_font_test.rb +44 -27
- data/test/rbpdf_format_test.rb +15 -11
- data/test/rbpdf_func_test.rb +26 -22
- data/test/rbpdf_html_anchor_test.rb +11 -13
- data/test/rbpdf_html_func_test.rb +34 -30
- data/test/rbpdf_html_test.rb +58 -5
- data/test/rbpdf_htmlcell_test.rb +10 -6
- data/test/rbpdf_http_test.rb +67 -0
- data/test/rbpdf_image_rmagick_test.rb +70 -87
- data/test/rbpdf_image_test.rb +86 -22
- data/test/rbpdf_test.rb +88 -90
- data/test/rbpdf_transaction_test.rb +4 -0
- data/test/rbpdf_viewerpreferences_test.rb +5 -1
- data/test/rbpdf_write_test.rb +49 -45
- data/test/test_helper.rb +5 -0
- data/test_unicode.rbpdf +4 -0
- metadata +22 -9
data/test/rbpdf_format_test.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Copyright (c) 2011-2017 NAITOH Jun
|
2
|
+
# Released under the MIT license
|
3
|
+
# http://www.opensource.org/licenses/MIT
|
4
|
+
|
1
5
|
require 'test_helper'
|
2
6
|
|
3
7
|
class RbpdfFormatTest < Test::Unit::TestCase
|
@@ -5,22 +9,22 @@ class RbpdfFormatTest < Test::Unit::TestCase
|
|
5
9
|
pdf = RBPDF.new
|
6
10
|
|
7
11
|
pagedim = pdf.set_page_orientation('')
|
8
|
-
assert_equal pagedim['or']
|
9
|
-
assert_equal pagedim['pb']
|
10
|
-
assert_equal pagedim['olm']
|
11
|
-
assert_equal pagedim['orm']
|
12
|
-
assert_in_delta pagedim['bm'],
|
12
|
+
assert_equal 'P', pagedim['or']
|
13
|
+
assert_equal true, pagedim['pb']
|
14
|
+
assert_equal nil, pagedim['olm']
|
15
|
+
assert_equal nil, pagedim['orm']
|
16
|
+
assert_in_delta 20, pagedim['bm'], 0.1
|
13
17
|
|
14
18
|
pagedim = pdf.set_page_orientation('P')
|
15
|
-
assert_equal pagedim['or']
|
19
|
+
assert_equal 'P', pagedim['or']
|
16
20
|
|
17
21
|
pagedim = pdf.set_page_orientation('L', false)
|
18
|
-
assert_equal pagedim['or']
|
19
|
-
assert_equal pagedim['pb']
|
22
|
+
assert_equal 'L', pagedim['or']
|
23
|
+
assert_equal false, pagedim['pb']
|
20
24
|
|
21
25
|
pagedim = pdf.set_page_orientation('P', true, 5)
|
22
|
-
assert_equal pagedim['or']
|
23
|
-
assert_equal pagedim['pb']
|
24
|
-
assert_equal pagedim['bm']
|
26
|
+
assert_equal 'P', pagedim['or']
|
27
|
+
assert_equal true, pagedim['pb']
|
28
|
+
assert_equal 5, pagedim['bm']
|
25
29
|
end
|
26
30
|
end
|
data/test/rbpdf_func_test.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Copyright (c) 2011-2017 NAITOH Jun
|
2
|
+
# Released under the MIT license
|
3
|
+
# http://www.opensource.org/licenses/MIT
|
4
|
+
|
1
5
|
require 'test_helper'
|
2
6
|
|
3
7
|
class RbpdfTest < Test::Unit::TestCase
|
@@ -10,71 +14,71 @@ class RbpdfTest < Test::Unit::TestCase
|
|
10
14
|
test "get_html_unit_to_units test" do
|
11
15
|
pdf = RBPDF.new
|
12
16
|
unit = pdf.get_html_unit_to_units("100", 1)
|
13
|
-
assert_in_delta
|
17
|
+
assert_in_delta 35.27, unit, 0.01
|
14
18
|
|
15
19
|
unit = pdf.get_html_unit_to_units("100px", 1, 'px', false)
|
16
|
-
assert_in_delta
|
20
|
+
assert_in_delta 35.27, unit, 0.01
|
17
21
|
|
18
22
|
unit = pdf.get_html_unit_to_units(100, 1, 'pt', false)
|
19
|
-
assert_in_delta
|
23
|
+
assert_in_delta 35.27, unit, 0.01
|
20
24
|
|
21
25
|
unit = pdf.get_html_unit_to_units(100.0, 1, 'pt', false)
|
22
|
-
assert_in_delta
|
26
|
+
assert_in_delta 35.27, unit, 0.01
|
23
27
|
|
24
28
|
unit = pdf.get_html_unit_to_units("100.0", 1, 'pt', false)
|
25
|
-
assert_in_delta
|
29
|
+
assert_in_delta 35.27, unit, 0.01
|
26
30
|
|
27
31
|
unit = pdf.get_html_unit_to_units("200", 1, '%', false)
|
28
|
-
assert_equal
|
32
|
+
assert_equal 2.0, unit
|
29
33
|
|
30
34
|
unit = pdf.get_html_unit_to_units("400%", 1, '%', false)
|
31
|
-
assert_equal
|
35
|
+
assert_equal 4.0, unit
|
32
36
|
|
33
37
|
unit = pdf.get_html_unit_to_units("10", 1, '%', false)
|
34
|
-
assert_equal
|
38
|
+
assert_equal 0.1, unit
|
35
39
|
|
36
40
|
unit = pdf.get_html_unit_to_units("10mm", 1, '%', false)
|
37
|
-
assert_in_delta
|
41
|
+
assert_in_delta 10, unit, 0.01
|
38
42
|
|
39
43
|
unit = pdf.get_html_unit_to_units("10", 1, 'mm', false)
|
40
|
-
assert_in_delta
|
44
|
+
assert_in_delta 10, unit, 0.01
|
41
45
|
|
42
46
|
unit = pdf.get_html_unit_to_units(10, 1, 'mm', false)
|
43
|
-
assert_in_delta
|
47
|
+
assert_in_delta 10, unit, 0.01
|
44
48
|
|
45
49
|
unit = pdf.get_html_unit_to_units("1", 1, 'cm', false)
|
46
|
-
assert_in_delta
|
50
|
+
assert_in_delta 10, unit, 0.01
|
47
51
|
|
48
52
|
unit = pdf.get_html_unit_to_units(10, 1, 'em', false)
|
49
|
-
assert_equal
|
53
|
+
assert_equal 10, unit
|
50
54
|
|
51
55
|
unit = pdf.get_html_unit_to_units(10, 2, 'em', false)
|
52
|
-
assert_equal
|
56
|
+
assert_equal 20, unit
|
53
57
|
end
|
54
58
|
|
55
59
|
test "getSpaceString test" do
|
56
60
|
pdf = MYPDF.new
|
57
61
|
spacestr = pdf.getSpaceString()
|
58
|
-
assert_equal
|
62
|
+
assert_equal 32.chr, spacestr
|
59
63
|
|
60
64
|
pdf.set_font('freesans', '', 18)
|
61
65
|
spacestr = pdf.getSpaceString()
|
62
|
-
assert_equal
|
66
|
+
assert_equal 0.chr + 32.chr, spacestr
|
63
67
|
end
|
64
68
|
|
65
69
|
test "revstrpos test" do
|
66
70
|
pdf = RBPDF.new
|
67
71
|
pos = pdf.revstrpos('abcd efgh ', 'cd')
|
68
|
-
assert_equal
|
72
|
+
assert_equal 2, pos
|
69
73
|
|
70
74
|
pos = pdf.revstrpos('abcd efgh ', 'cd ')
|
71
|
-
assert_equal
|
75
|
+
assert_equal 2, pos
|
72
76
|
|
73
77
|
pos = pdf.revstrpos('abcd efgh abcd efg', 'cd')
|
74
|
-
assert_equal
|
78
|
+
assert_equal 12, pos
|
75
79
|
|
76
80
|
pos = pdf.revstrpos('abcd efgh abcd efg', 'zy')
|
77
|
-
assert_equal
|
81
|
+
assert_equal nil, pos
|
78
82
|
end
|
79
83
|
|
80
84
|
test "revstrpos offset test 1" do
|
@@ -129,7 +133,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
129
133
|
|
130
134
|
pdf = RBPDF.new
|
131
135
|
str = 'test'.force_encoding('UTF-8')
|
132
|
-
|
133
|
-
assert_equal str.encoding.to_s
|
136
|
+
pdf.get_string_width(str)
|
137
|
+
assert_equal 'UTF-8', str.encoding.to_s
|
134
138
|
end
|
135
139
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
+
# Copyright (c) 2011-2017 NAITOH Jun
|
2
|
+
# Released under the MIT license
|
3
|
+
# http://www.opensource.org/licenses/MIT
|
4
|
+
|
1
5
|
require 'test_helper'
|
2
6
|
|
3
7
|
class RbpdfTest < Test::Unit::TestCase
|
4
|
-
class MYPDF < RBPDF
|
5
|
-
def getPageBuffer(page)
|
6
|
-
super
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
8
|
test "anchor with text inside" do
|
11
9
|
pdf = RBPDF.new
|
12
10
|
pdf.add_page()
|
@@ -15,7 +13,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
15
13
|
pdf.write_html(htmlcontent, true, 0, true, 0)
|
16
14
|
|
17
15
|
position = pdf.get_html_anchor_position('foo')
|
18
|
-
assert_equal
|
16
|
+
assert_equal [1, 10.001249999999999], position
|
19
17
|
end
|
20
18
|
|
21
19
|
test "anchor with id" do
|
@@ -26,7 +24,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
26
24
|
pdf.write_html(htmlcontent, true, 0, true, 0)
|
27
25
|
|
28
26
|
position = pdf.get_html_anchor_position('foo')
|
29
|
-
assert_equal
|
27
|
+
assert_equal [1, 10.001249999999999], position
|
30
28
|
end
|
31
29
|
|
32
30
|
test "empty anchor" do
|
@@ -37,7 +35,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
37
35
|
pdf.write_html(htmlcontent, true, 0, true, 0)
|
38
36
|
|
39
37
|
position = pdf.get_html_anchor_position('foo')
|
40
|
-
assert_equal
|
38
|
+
assert_equal [1, 10.001249999999999], position
|
41
39
|
end
|
42
40
|
|
43
41
|
|
@@ -49,7 +47,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
49
47
|
pdf.write_html(htmlcontent, true, 0, true, 0)
|
50
48
|
|
51
49
|
position = pdf.get_html_anchor_position('foo')
|
52
|
-
assert_equal
|
50
|
+
assert_equal [1, 57.626249999999985], position
|
53
51
|
end
|
54
52
|
|
55
53
|
|
@@ -63,7 +61,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
63
61
|
pdf.write_html(htmlcontent, true, 0, true, 0)
|
64
62
|
|
65
63
|
position = pdf.get_html_anchor_position('foo')
|
66
|
-
assert_equal
|
64
|
+
assert_equal [3, 68.20958333333331], position
|
67
65
|
end
|
68
66
|
|
69
67
|
|
@@ -82,7 +80,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
82
80
|
|
83
81
|
pdf.send(:mapLinksToHtmlAnchors)
|
84
82
|
link_position = pdf.instance_variable_get(:@links)[1]
|
85
|
-
assert_equal
|
83
|
+
assert_equal [3, 73.50124999999998], link_position
|
86
84
|
end
|
87
85
|
|
88
86
|
test "maps when anchor before link" do
|
@@ -101,7 +99,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
101
99
|
pdf.send(:mapLinksToHtmlAnchors)
|
102
100
|
|
103
101
|
link_position = pdf.instance_variable_get(:@links)[1]
|
104
|
-
assert_equal
|
102
|
+
assert_equal [1, 10.001249999999999], link_position
|
105
103
|
end
|
106
104
|
|
107
105
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# Copyright (c) 2011-2017 NAITOH Jun
|
2
|
+
# Released under the MIT license
|
3
|
+
# http://www.opensource.org/licenses/MIT
|
4
|
+
|
1
5
|
require 'test_helper'
|
2
6
|
|
3
7
|
class RbpdfTest < Test::Unit::TestCase
|
@@ -21,8 +25,8 @@ class RbpdfTest < Test::Unit::TestCase
|
|
21
25
|
pdf.addHTMLVertSpace(1, 0, false, true)
|
22
26
|
x2 = pdf.get_x
|
23
27
|
y2 = pdf.get_y
|
24
|
-
assert_equal
|
25
|
-
assert_equal
|
28
|
+
assert_equal x1, x2
|
29
|
+
assert_equal y1, y2
|
26
30
|
|
27
31
|
# same line, @c_margin position
|
28
32
|
margins = pdf.get_margins
|
@@ -32,8 +36,8 @@ class RbpdfTest < Test::Unit::TestCase
|
|
32
36
|
pdf.addHTMLVertSpace(1, 0, true, true)
|
33
37
|
x2 = pdf.get_x
|
34
38
|
y2 = pdf.get_y
|
35
|
-
assert_equal
|
36
|
-
assert_equal y2
|
39
|
+
assert_equal x1 + margins['cell'], x2
|
40
|
+
assert_equal y1, y2
|
37
41
|
end
|
38
42
|
|
39
43
|
test "html func addHTMLVertSpace add line test" do
|
@@ -47,8 +51,8 @@ class RbpdfTest < Test::Unit::TestCase
|
|
47
51
|
pdf.addHTMLVertSpace(5, 0, false, false)
|
48
52
|
x2 = pdf.get_x
|
49
53
|
y2 = pdf.get_y
|
50
|
-
assert_equal x2
|
51
|
-
assert_equal
|
54
|
+
assert_equal x1, x2
|
55
|
+
assert_equal y1 + 5, y2
|
52
56
|
|
53
57
|
# next line, @c_margin position
|
54
58
|
margins = pdf.get_margins
|
@@ -58,8 +62,8 @@ class RbpdfTest < Test::Unit::TestCase
|
|
58
62
|
pdf.addHTMLVertSpace(5, 0, true, false)
|
59
63
|
x2 = pdf.get_x
|
60
64
|
y2 = pdf.get_y
|
61
|
-
assert_equal
|
62
|
-
assert_equal
|
65
|
+
assert_equal x1 + margins['cell'], x2
|
66
|
+
assert_equal y1 + 5, y2
|
63
67
|
end
|
64
68
|
|
65
69
|
test "html func addHTMLVertSpace height of the break test 1" do
|
@@ -72,44 +76,44 @@ class RbpdfTest < Test::Unit::TestCase
|
|
72
76
|
pdf.addHTMLVertSpace(0, 5, true, false) # height of the break : 5
|
73
77
|
x2 = pdf.get_x
|
74
78
|
y2 = pdf.get_y
|
75
|
-
assert_equal
|
76
|
-
assert_equal
|
79
|
+
assert_equal x1 + margins['cell'], x2
|
80
|
+
assert_equal y1 + 5, y2
|
77
81
|
|
78
82
|
pdf.addHTMLVertSpace(0, 5, true, false) # height of the break : 5
|
79
83
|
x3 = pdf.get_x
|
80
84
|
y3 = pdf.get_y
|
81
|
-
assert_equal
|
82
|
-
assert_equal
|
85
|
+
assert_equal x2, x3
|
86
|
+
assert_equal y2, y3
|
83
87
|
|
84
88
|
pdf.addHTMLVertSpace(0, 5 + 2, true, false) # height of the break : 7
|
85
89
|
x4 = pdf.get_x
|
86
90
|
y4 = pdf.get_y
|
87
|
-
assert_equal x4
|
88
|
-
assert_equal
|
91
|
+
assert_equal x3, x4
|
92
|
+
assert_equal y3 + 2, y4
|
89
93
|
|
90
94
|
pdf.addHTMLVertSpace(0, 5, true, false) # height of the break : 7
|
91
95
|
x5 = pdf.get_x
|
92
96
|
y5 = pdf.get_y
|
93
|
-
assert_equal
|
94
|
-
assert_equal
|
97
|
+
assert_equal x4, x5
|
98
|
+
assert_equal y4, y5
|
95
99
|
|
96
100
|
pdf.addHTMLVertSpace(0, 5 + 2 + 1, true, false) # height of the break : 8
|
97
101
|
x6 = pdf.get_x
|
98
102
|
y6 = pdf.get_y
|
99
|
-
assert_equal x6
|
100
|
-
assert_equal
|
103
|
+
assert_equal x5, x6
|
104
|
+
assert_equal y5 + 1, y6
|
101
105
|
|
102
106
|
pdf.addHTMLVertSpace(0, 10, true, true) # height of the break : 0 (reset)
|
103
107
|
x7 = pdf.get_x
|
104
108
|
y7 = pdf.get_y
|
105
|
-
assert_equal
|
106
|
-
assert_equal
|
109
|
+
assert_equal x6, x7
|
110
|
+
assert_equal y6, y7
|
107
111
|
|
108
112
|
pdf.addHTMLVertSpace(0, 2, true, false) # height of the break : 2
|
109
113
|
x8 = pdf.get_x
|
110
114
|
y8 = pdf.get_y
|
111
|
-
assert_equal x8
|
112
|
-
assert_equal
|
115
|
+
assert_equal x7, x8
|
116
|
+
assert_equal y7 + 2, y8
|
113
117
|
end
|
114
118
|
|
115
119
|
test "html func addHTMLVertSpace height of the break test 2" do
|
@@ -121,20 +125,20 @@ class RbpdfTest < Test::Unit::TestCase
|
|
121
125
|
pdf.addHTMLVertSpace(10, 5, false, false) # height of the break : 5
|
122
126
|
x2 = pdf.get_x
|
123
127
|
y2 = pdf.get_y
|
124
|
-
assert_equal x2
|
125
|
-
assert_equal
|
128
|
+
assert_equal x1, x2
|
129
|
+
assert_equal y1 + 10 + 5, y2
|
126
130
|
|
127
131
|
pdf.addHTMLVertSpace(10, 5, false, false) # height of the break : 5
|
128
132
|
x3 = pdf.get_x
|
129
133
|
y3 = pdf.get_y
|
130
|
-
assert_equal x3
|
131
|
-
assert_equal
|
134
|
+
assert_equal x2, x3
|
135
|
+
assert_equal y2 + 10, y3
|
132
136
|
|
133
137
|
pdf.addHTMLVertSpace(10, 5 + 2, false, false) # height of the break : 7
|
134
138
|
x4 = pdf.get_x
|
135
139
|
y4 = pdf.get_y
|
136
|
-
assert_equal x4
|
137
|
-
assert_equal
|
140
|
+
assert_equal x3, x4
|
141
|
+
assert_equal y3 + 10 + 2, y4
|
138
142
|
end
|
139
143
|
|
140
144
|
test "html func sanitize test 1" do
|
@@ -143,7 +147,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
143
147
|
html = '<table border="1"><thead><tr><td>ABCD</td><td>EFGH</td><td>IJKL</td></tr></thead><tr><td>abcd</td><td>efgh</td><td>ijkl</td></tr><tr><td>' + 'ABC' + '</td></tr></table>'
|
144
148
|
html = pdf.sanitize_html(html).gsub(/[\r\n]/,'')
|
145
149
|
|
146
|
-
assert_equal
|
150
|
+
assert_equal %{<table border="1"><thead><tr><td>ABCD</td><td>EFGH</td><td>IJKL</td></tr></thead><tr><td>abcd</td><td>efgh</td><td>ijkl</td></tr><tr><td>ABC</td></tr></table>}, html
|
147
151
|
end
|
148
152
|
|
149
153
|
test "html func sanitize test 2" do
|
@@ -153,7 +157,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
153
157
|
htmlcontent = '1<br><br><br><br><br><br><br><br><br><br> 2<br><br><br><br><br><br><br><br><br><br> 3<br><br><br><br><br><br><br><br><br><br> 4<br><br><br><br><br><br><br><br><br><br> 5<br><br><br><br><br><br><br><br><br><br> 6<br><br><br><br><br><br><br><br><br><br> 7<br><br><br><br><br><br><br><br><br><br> 8<br><br><br><br><br><br><br><br><br><br> 9<br><br><br><br><br><br><br><br><br><br> 10<br><br><br><br><br><br><br><br><br><br> 11<br><br><br><br><br><br><br><br><br><br>'
|
154
158
|
html = '<table cellpadding="1"><thead><tr><td>ABCD</td><td>EFGH</td><td>IJKL</td></tr></thead><tr><td>abcd</td><td>efgh</td><td>ijkl</td></tr><tr><td>' + htmlcontent + '</td></tr></table>'
|
155
159
|
html = pdf.sanitize_html(html).gsub(/[\r\n]/,'')
|
156
|
-
assert_equal
|
160
|
+
assert_equal %{<table cellpadding="1"><thead><tr><td>ABCD</td><td>EFGH</td><td>IJKL</td></tr></thead><tr><td>abcd</td><td>efgh</td><td>ijkl</td></tr><tr><td>1<br><br><br><br><br><br><br><br><br><br> 2<br><br><br><br><br><br><br><br><br><br> 3<br><br><br><br><br><br><br><br><br><br> 4<br><br><br><br><br><br><br><br><br><br> 5<br><br><br><br><br><br><br><br><br><br> 6<br><br><br><br><br><br><br><br><br><br> 7<br><br><br><br><br><br><br><br><br><br> 8<br><br><br><br><br><br><br><br><br><br> 9<br><br><br><br><br><br><br><br><br><br> 10<br><br><br><br><br><br><br><br><br><br> 11<br><br><br><br><br><br><br><br><br><br></td></tr></table>}, html
|
157
161
|
end
|
158
162
|
|
159
163
|
test "html func sanitize open angled bracket '<' test" do
|
data/test/rbpdf_html_test.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
# coding: ASCII-8BIT
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011-2017 NAITOH Jun
|
4
|
+
# Released under the MIT license
|
5
|
+
# http://www.opensource.org/licenses/MIT
|
6
|
+
|
2
7
|
require 'test_helper'
|
3
8
|
|
4
9
|
class RbpdfHtmlTest < Test::Unit::TestCase
|
@@ -74,7 +79,7 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
74
79
|
pdf.write_html(htmlcontent, true, 0, true, 0)
|
75
80
|
|
76
81
|
pno = pdf.get_page
|
77
|
-
assert_equal
|
82
|
+
assert_equal 3, pno
|
78
83
|
end
|
79
84
|
|
80
85
|
test "write_html Table test 1" do
|
@@ -90,7 +95,7 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
90
95
|
pdf.write_html(tablehtml, true, 0, true, 0)
|
91
96
|
|
92
97
|
pno = pdf.get_page
|
93
|
-
assert_equal
|
98
|
+
assert_equal 3, pno
|
94
99
|
end
|
95
100
|
|
96
101
|
test "write_html Table test 2" do
|
@@ -105,7 +110,7 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
105
110
|
pdf.write_html(tablehtml, true, 0, true, 0)
|
106
111
|
|
107
112
|
pno = pdf.get_page
|
108
|
-
assert_equal
|
113
|
+
assert_equal 3, pno
|
109
114
|
|
110
115
|
# Page 1
|
111
116
|
count_line, count_text, xpos1 = pdf.get_html_text_position_x(1, /ABCD/) # Header
|
@@ -395,7 +400,7 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
395
400
|
content.each do |line|
|
396
401
|
count_text += 1 unless line.scan(text).empty?
|
397
402
|
end
|
398
|
-
assert_equal
|
403
|
+
assert_equal 1, count_text
|
399
404
|
end
|
400
405
|
|
401
406
|
test "write_html Non ASCII text test" do
|
@@ -420,7 +425,7 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
420
425
|
line.force_encoding('ASCII-8BIT') if line.respond_to?(:force_encoding)
|
421
426
|
count_text += 1 unless line.scan(text).empty?
|
422
427
|
end
|
423
|
-
assert_equal
|
428
|
+
assert_equal 1, count_text
|
424
429
|
end
|
425
430
|
|
426
431
|
test "works internal links out of page range" do
|
@@ -439,6 +444,28 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
439
444
|
end
|
440
445
|
end
|
441
446
|
|
447
|
+
test "write_html no tag text test" do
|
448
|
+
pdf = MYPDF.new
|
449
|
+
pdf.set_print_header(false)
|
450
|
+
pdf.add_page()
|
451
|
+
|
452
|
+
text = ' abc def '
|
453
|
+
pdf.write_html(text, true, 0, true, 0)
|
454
|
+
pdf_text = pdf.get_html_text(1)
|
455
|
+
assert_equal 'abc def', pdf_text
|
456
|
+
end
|
457
|
+
|
458
|
+
test "write_html no tag back slash test" do
|
459
|
+
pdf = MYPDF.new
|
460
|
+
pdf.set_print_header(false)
|
461
|
+
pdf.add_page()
|
462
|
+
|
463
|
+
text = " abc \\def "
|
464
|
+
pdf.write_html(text, true, 0, true, 0) # use escape() method in getCellCode()
|
465
|
+
pdf_text = pdf.get_html_text(1)
|
466
|
+
assert_equal "abc \\\\def", pdf_text
|
467
|
+
end
|
468
|
+
|
442
469
|
test "write_html <b> tag test" do
|
443
470
|
pdf = MYPDF.new
|
444
471
|
pdf.set_print_header(false)
|
@@ -504,6 +531,32 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
504
531
|
assert_equal "\xa0" * 2 + 'A' * 70, pdf_text
|
505
532
|
end
|
506
533
|
|
534
|
+
test "write_html <table> tag text test" do
|
535
|
+
pdf = MYPDF.new
|
536
|
+
pdf.set_print_header(false)
|
537
|
+
pdf.add_page()
|
538
|
+
|
539
|
+
text = "abc"
|
540
|
+
htmlcontent = '<table border="1"><tr><td>' + text + '</td></tr></table>'
|
541
|
+
|
542
|
+
pdf.write_html(htmlcontent, true, 0, true, 0)
|
543
|
+
pdf_text = pdf.get_html_text(1)
|
544
|
+
assert_equal 'abc', pdf_text
|
545
|
+
end
|
546
|
+
|
547
|
+
test "write_html <table> tag back slash test" do
|
548
|
+
pdf = MYPDF.new
|
549
|
+
pdf.set_print_header(false)
|
550
|
+
pdf.add_page()
|
551
|
+
|
552
|
+
text = "a\\bc"
|
553
|
+
htmlcontent = '<table border="1"><tr><td>' + text + '</td></tr></table>'
|
554
|
+
|
555
|
+
pdf.write_html(htmlcontent, true, 0, true, 0) # use escape() method in getCellCode()
|
556
|
+
pdf_text = pdf.get_html_text(1)
|
557
|
+
assert_equal 'a\\\\bc', pdf_text
|
558
|
+
end
|
559
|
+
|
507
560
|
test "write_html Character Entities test" do
|
508
561
|
pdf = MYPDF.new
|
509
562
|
pdf.set_print_header(false)
|