rbpdf 1.20.0 → 1.20.1
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 +4 -4
- data/CHANGELOG +4 -0
- data/lib/rbpdf/version.rb +1 -1
- data/rbpdf.gemspec +1 -2
- metadata +4 -90
- 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
@@ -1,41 +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 RbpdfPageTest < Test::Unit::TestCase
|
8
|
-
class MYPDF < RBPDF
|
9
|
-
def putviewerpreferences
|
10
|
-
super
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
test "viewerpreferences test" do
|
15
|
-
# set array for viewer preferences
|
16
|
-
preferences = {
|
17
|
-
'HideToolbar' => true,
|
18
|
-
'HideMenubar' => true,
|
19
|
-
'HideWindowUI' => true,
|
20
|
-
'FitWindow' => true,
|
21
|
-
'CenterWindow' => true,
|
22
|
-
'DisplayDocTitle' => true,
|
23
|
-
'NonFullScreenPageMode' => 'UseNone', # UseNone, UseOutlines, UseThumbs, UseOC
|
24
|
-
'ViewArea' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox
|
25
|
-
'ViewClip' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox
|
26
|
-
'PrintArea' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox
|
27
|
-
'PrintClip' => 'CropBox', # CropBox, BleedBox, TrimBox, ArtBox
|
28
|
-
'PrintScaling' => 'AppDefault', # None, AppDefault
|
29
|
-
'Duplex' => 'DuplexFlipLongEdge', # Simplex, DuplexFlipShortEdge, DuplexFlipLongEdge
|
30
|
-
'PickTrayByPDFSize' => true,
|
31
|
-
'PrintPageRange' => [1,1,2,3],
|
32
|
-
'NumCopies' => 2
|
33
|
-
}
|
34
|
-
|
35
|
-
pdf = MYPDF.new
|
36
|
-
pdf.set_viewer_preferences(preferences)
|
37
|
-
out = pdf.putviewerpreferences()
|
38
|
-
|
39
|
-
assert_equal '/ViewerPreferences << /Direction /L2R /HideToolbar true /HideMenubar true /HideWindowUI true /FitWindow true /CenterWindow true /DisplayDocTitle true /NonFullScreenPageMode /UseNone /ViewArea /CropBox /ViewClip /CropBox /PrintArea /CropBox /PrintClip /CropBox /PrintScaling /AppDefault /Duplex /DuplexFlipLongEdge /PickTrayByPDFSize true /PrintPageRange [0 0 1 2] /NumCopies 2 >>', out
|
40
|
-
end
|
41
|
-
end
|
data/test/rbpdf_write_test.rb
DELETED
@@ -1,229 +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
|
-
test "write Basic test" do
|
9
|
-
pdf = RBPDF.new
|
10
|
-
|
11
|
-
line = pdf.write(0, "LINE 1")
|
12
|
-
assert_equal 1, line
|
13
|
-
|
14
|
-
line = pdf.write(0, "LINE 1\n")
|
15
|
-
assert_equal 1, line
|
16
|
-
|
17
|
-
line = pdf.write(0, "LINE 1\n2\n")
|
18
|
-
assert_equal 2, line
|
19
|
-
|
20
|
-
line = pdf.write(0, "")
|
21
|
-
assert_equal 1, line
|
22
|
-
|
23
|
-
line = pdf.write(0, "\n")
|
24
|
-
assert_equal 1, line
|
25
|
-
|
26
|
-
line = pdf.write(0, "abcdefghijklmnopgrstuvwxyz01234567890")
|
27
|
-
assert_equal 1, line
|
28
|
-
line = pdf.write(0, "abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890")
|
29
|
-
assert_equal 2, line
|
30
|
-
line = pdf.write(0, "abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890")
|
31
|
-
assert_equal 3, line
|
32
|
-
end
|
33
|
-
|
34
|
-
test "write Break test single line 1" do
|
35
|
-
pdf = RBPDF.new
|
36
|
-
pdf.add_page()
|
37
|
-
|
38
|
-
cell_hight = pdf.get_cell_height_ratio()
|
39
|
-
fontsize = pdf.get_font_size()
|
40
|
-
break_hight = pdf.set_auto_page_break(true)
|
41
|
-
|
42
|
-
pno = pdf.get_page
|
43
|
-
assert_equal 1, pno
|
44
|
-
|
45
|
-
0.upto(60) do |i|
|
46
|
-
y = pdf.get_y()
|
47
|
-
old_pno = pno
|
48
|
-
|
49
|
-
line = pdf.write(0, "LINE 1\n")
|
50
|
-
assert_equal 1, line
|
51
|
-
|
52
|
-
pno = pdf.get_page
|
53
|
-
|
54
|
-
if y + fontsize * cell_hight < break_hight
|
55
|
-
assert_equal old_pno, pno
|
56
|
-
else
|
57
|
-
assert_equal old_pno + 1, pno
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
test "write Break test single line 2" do
|
63
|
-
pdf = RBPDF.new
|
64
|
-
pdf.add_page()
|
65
|
-
|
66
|
-
0.upto(49) do |i|
|
67
|
-
line = pdf.write(0, "LINE 1\n")
|
68
|
-
assert_equal 1, line
|
69
|
-
|
70
|
-
pno = pdf.get_page
|
71
|
-
assert_equal 1, pno
|
72
|
-
end
|
73
|
-
|
74
|
-
line = pdf.write(0, "abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890 abcdefghijklmnopgrstuvwxyz01234567890")
|
75
|
-
assert_equal 2, line
|
76
|
-
pno = pdf.get_page
|
77
|
-
assert_equal 2, pno
|
78
|
-
end
|
79
|
-
|
80
|
-
test "write Break test multi line 1" do
|
81
|
-
pdf = RBPDF.new
|
82
|
-
pdf.add_page()
|
83
|
-
pno = pdf.get_page
|
84
|
-
assert_equal 1, pno
|
85
|
-
|
86
|
-
line = pdf.write(0, "1\n\n\n\n\n\n\n\n\n\n 2\n\n\n\n\n\n\n\n\n\n 3\n\n\n\n\n\n\n\n\n\n 4\n\n\n\n\n\n\n\n\n\n")
|
87
|
-
assert_equal 40, line
|
88
|
-
pno = pdf.get_page
|
89
|
-
assert_equal 1, pno
|
90
|
-
|
91
|
-
line = pdf.write(0, "1\n\n\n\n\n\n\n\n\n\n 2\n\n\n\n\n\n\n\n\n\n 3\n\n\n\n\n\n\n\n\n\n 4\n\n\n\n\n\n\n\n\n\n")
|
92
|
-
assert_equal 40, line
|
93
|
-
pno = pdf.get_page
|
94
|
-
assert_equal 2, pno
|
95
|
-
end
|
96
|
-
|
97
|
-
test "write Break test multi line 2" do
|
98
|
-
pdf = RBPDF.new
|
99
|
-
pdf.add_page()
|
100
|
-
pno = pdf.get_page
|
101
|
-
assert_equal 1, pno
|
102
|
-
|
103
|
-
line = pdf.write(0, "1\n\n\n\n\n\n\n\n\n\n 2\n\n\n\n\n\n\n\n\n\n 3\n\n\n\n\n\n\n\n\n\n 4\n\n\n\n\n\n\n\n\n\n 5\n\n\n\n\n\n\n\n\n\n 6\n\n\n\n\n\n\n\n\n\n 7\n\n\n\n\n\n\n\n\n\n 8\n\n\n\n\n\n\n\n\n\n 9\n\n\n\n\n\n\n\n\n\n 10\n\n\n\n\n\n\n\n\n\n 11\n\n\n\n\n\n\n\n\n\n")
|
104
|
-
assert_equal 110, line
|
105
|
-
pno = pdf.get_page
|
106
|
-
assert_equal 3, pno
|
107
|
-
end
|
108
|
-
|
109
|
-
test "write firstline test" do
|
110
|
-
pdf = RBPDF.new
|
111
|
-
pdf.add_page()
|
112
|
-
pno = pdf.get_page
|
113
|
-
assert_equal 1, pno
|
114
|
-
|
115
|
-
line = pdf.write(0, "\n", nil, 0, '', false, 0, true)
|
116
|
-
assert_equal "\n", line
|
117
|
-
|
118
|
-
line = pdf.write(0, "\n", nil, 0, '', false, 0, true)
|
119
|
-
assert_equal "\n", line
|
120
|
-
|
121
|
-
line = pdf.write(0, "12345\n", nil, 0, '', false, 0, true)
|
122
|
-
assert_equal "\n", line
|
123
|
-
|
124
|
-
line = pdf.write(0, "12345\nabcde", nil, 0, '', false, 0, true)
|
125
|
-
assert_equal "\nabcde", line
|
126
|
-
|
127
|
-
line = pdf.write(0, "12345\nabcde\n", nil, 0, '', false, 0, true)
|
128
|
-
assert_equal "\nabcde\n", line
|
129
|
-
|
130
|
-
line = pdf.write(0, "12345\nabcde\nefgh", nil, 0, '', false, 0, true)
|
131
|
-
assert_equal "\nabcde\nefgh", line
|
132
|
-
end
|
133
|
-
|
134
|
-
class MYPDF < RBPDF
|
135
|
-
def endlinex
|
136
|
-
@endlinex
|
137
|
-
end
|
138
|
-
def r_margin
|
139
|
-
@r_margin
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
test "write endline x test 1" do
|
144
|
-
pdf = MYPDF.new
|
145
|
-
pdf.add_page()
|
146
|
-
pdf.write(0, " cccccccccc cccccccccc ", nil, 0, '', false, 0, true)
|
147
|
-
endlinex = pdf.endlinex()
|
148
|
-
assert_not_equal 0, endlinex
|
149
|
-
end
|
150
|
-
|
151
|
-
test "write endline x test 2" do
|
152
|
-
pdf = MYPDF.new
|
153
|
-
pdf.add_page()
|
154
|
-
|
155
|
-
r_margin = pdf.r_margin()
|
156
|
-
width = pdf.getPageWidth()
|
157
|
-
x = width - r_margin - 10
|
158
|
-
pdf.SetX(x)
|
159
|
-
pdf.write(0, " cccccccccc cccccccccc ", nil, 0, '', false, 0, true)
|
160
|
-
endlinex = pdf.endlinex()
|
161
|
-
assert_equal x, endlinex
|
162
|
-
end
|
163
|
-
|
164
|
-
test "write endline x test 3" do
|
165
|
-
pdf = MYPDF.new
|
166
|
-
pdf.add_page()
|
167
|
-
|
168
|
-
r_margin = pdf.r_margin()
|
169
|
-
width = pdf.getPageWidth()
|
170
|
-
x = width - r_margin - 10
|
171
|
-
pdf.SetX(x)
|
172
|
-
pdf.write(0, "cccccccccc cccccccccc ", nil, 0, '', false, 0, true)
|
173
|
-
endlinex = pdf.endlinex()
|
174
|
-
assert_not_equal x, endlinex
|
175
|
-
end
|
176
|
-
|
177
|
-
test "write encoding test" do
|
178
|
-
return unless 'test'.respond_to?(:force_encoding)
|
179
|
-
|
180
|
-
pdf = RBPDF.new('P', 'mm', 'A4', true, "UTF-8", true)
|
181
|
-
str = 'test'.force_encoding('UTF-8')
|
182
|
-
pdf.write(0, str)
|
183
|
-
assert_equal 'UTF-8', str.encoding.to_s
|
184
|
-
end
|
185
|
-
|
186
|
-
test "write Bidi arabic test" do
|
187
|
-
pdf = RBPDF.new
|
188
|
-
pdf.set_font('dejavusans', '', 18)
|
189
|
-
pdf.add_page
|
190
|
-
|
191
|
-
ascii_str = "role"
|
192
|
-
utf8_arabic_str_1 = "\xd8\xaf\xd9\x88\xd8\xb1"
|
193
|
-
|
194
|
-
line = pdf.write(0, ascii_str)
|
195
|
-
assert_equal 1, line
|
196
|
-
line = pdf.write(0, utf8_arabic_str_1)
|
197
|
-
assert_equal 1, line
|
198
|
-
end
|
199
|
-
|
200
|
-
test "write Bidi arabic set_rtl test" do
|
201
|
-
pdf = RBPDF.new
|
202
|
-
pdf.set_font('dejavusans', '', 18)
|
203
|
-
pdf.set_rtl(true)
|
204
|
-
pdf.add_page
|
205
|
-
|
206
|
-
ascii_str = "role"
|
207
|
-
utf8_arabic_str_1 = "\xd8\xaf\xd9\x88\xd8\xb1"
|
208
|
-
|
209
|
-
line = pdf.write(0, ascii_str)
|
210
|
-
assert_equal 1, line
|
211
|
-
line = pdf.write(0, utf8_arabic_str_1)
|
212
|
-
assert_equal 1, line
|
213
|
-
end
|
214
|
-
|
215
|
-
test "write Bidi arabic set_temp_rtl test" do
|
216
|
-
pdf = RBPDF.new
|
217
|
-
pdf.set_font('dejavusans', '', 18)
|
218
|
-
pdf.set_temp_rtl('rtl')
|
219
|
-
pdf.add_page
|
220
|
-
|
221
|
-
ascii_str = "role"
|
222
|
-
utf8_arabic_str_1 = "\xd8\xaf\xd9\x88\xd8\xb1"
|
223
|
-
|
224
|
-
line = pdf.write(0, ascii_str)
|
225
|
-
assert_equal 1, line
|
226
|
-
line = pdf.write(0, utf8_arabic_str_1)
|
227
|
-
assert_equal 1, line
|
228
|
-
end
|
229
|
-
end
|
data/test/test.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'mini_magick'
|
2
|
-
|
3
|
-
# => {"red"=>"8-bit", "green"=>"8-bit", "blue"=>"8-bit", "alpha"=>"8-bit"}
|
4
|
-
# `mogrify -alpha on -red off -green off -blue off /tmp/mini_magick20190806-29273-5pt5pu.png`
|
5
|
-
# convert drawn.png -channel matte -separate +matte matte.png
|
6
|
-
#img = MiniMagick::Image.open('input.jpg')
|
7
|
-
img = MiniMagick::Image.open('png_test_alpha.png')
|
8
|
-
#img.format('png')
|
9
|
-
img.combine_options do |mogrify|
|
10
|
-
# mogrify.alpha 'on'
|
11
|
-
# mogrify.red 'off'
|
12
|
-
# mogrify.green 'off'
|
13
|
-
# mogrify.blue 'off'
|
14
|
-
mogrify.channel 'matte'
|
15
|
-
mogrify.separate '+matte'
|
16
|
-
# convert.channel 'matte'
|
17
|
-
# convert.separate '+matte'
|
18
|
-
# mogrify.alpha 'on'
|
19
|
-
# mogrify.channel 'a'
|
20
|
-
# mogrify.evaluate 'set', '25%'
|
21
|
-
end
|
22
|
-
img.write('output.png')
|