eideticpdf 0.9.9
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/fonts/AntiqueOlive-Bold.afm +406 -0
- data/fonts/AntiqueOlive-Bold.inf +27 -0
- data/fonts/AntiqueOlive-Compact.afm +401 -0
- data/fonts/AntiqueOlive-Compact.inf +27 -0
- data/fonts/AntiqueOlive-Italic.afm +401 -0
- data/fonts/AntiqueOlive-Italic.inf +27 -0
- data/fonts/AntiqueOlive-Roman.afm +409 -0
- data/fonts/AntiqueOlive-Roman.inf +27 -0
- data/fonts/AvantGarde-Book.afm +667 -0
- data/fonts/AvantGarde-Book.inf +26 -0
- data/fonts/AvantGarde-BookOblique.afm +667 -0
- data/fonts/AvantGarde-BookOblique.inf +26 -0
- data/fonts/AvantGarde-Demi.afm +673 -0
- data/fonts/AvantGarde-Demi.inf +26 -0
- data/fonts/AvantGarde-DemiOblique.afm +673 -0
- data/fonts/AvantGarde-DemiOblique.inf +26 -0
- data/fonts/Bookman-Demi.afm +669 -0
- data/fonts/Bookman-Demi.inf +25 -0
- data/fonts/Bookman-DemiItalic.afm +669 -0
- data/fonts/Bookman-DemiItalic.inf +25 -0
- data/fonts/Bookman-Light.afm +643 -0
- data/fonts/Bookman-Light.inf +25 -0
- data/fonts/Bookman-LightItalic.afm +620 -0
- data/fonts/Bookman-LightItalic.inf +25 -0
- data/fonts/Clarendon-Bold.afm +412 -0
- data/fonts/Clarendon-Bold.inf +27 -0
- data/fonts/Clarendon-Light.afm +410 -0
- data/fonts/Clarendon-Light.inf +27 -0
- data/fonts/Clarendon.afm +410 -0
- data/fonts/Clarendon.inf +27 -0
- data/fonts/CooperBlack-Italic.afm +421 -0
- data/fonts/CooperBlack-Italic.inf +26 -0
- data/fonts/CooperBlack.afm +427 -0
- data/fonts/CooperBlack.inf +26 -0
- data/fonts/Coronet-Regular.afm +327 -0
- data/fonts/Coronet-Regular.inf +25 -0
- data/fonts/Courier-Bold.afm +342 -0
- data/fonts/Courier-Bold.inf +26 -0
- data/fonts/Courier-BoldOblique.afm +342 -0
- data/fonts/Courier-BoldOblique.inf +26 -0
- data/fonts/Courier-Oblique.afm +342 -0
- data/fonts/Courier-Oblique.inf +26 -0
- data/fonts/Courier.afm +342 -0
- data/fonts/Courier.inf +26 -0
- data/fonts/Eurostile.afm +419 -0
- data/fonts/Eurostile.inf +27 -0
- data/fonts/Goudy-ExtraBold.afm +412 -0
- data/fonts/Goudy-ExtraBold.inf +27 -0
- data/fonts/Helvetica-Bold.afm +2827 -0
- data/fonts/Helvetica-Bold.inf +26 -0
- data/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/fonts/Helvetica-BoldOblique.inf +26 -0
- data/fonts/Helvetica-Condensed-Bold.afm +623 -0
- data/fonts/Helvetica-Condensed-Bold.inf +25 -0
- data/fonts/Helvetica-Condensed-BoldObl.afm +623 -0
- data/fonts/Helvetica-Condensed-BoldObl.inf +25 -0
- data/fonts/Helvetica-Condensed-Oblique.afm +528 -0
- data/fonts/Helvetica-Condensed-Oblique.inf +25 -0
- data/fonts/Helvetica-Condensed.afm +528 -0
- data/fonts/Helvetica-Condensed.inf +25 -0
- data/fonts/Helvetica-Narrow-Bold.afm +1439 -0
- data/fonts/Helvetica-Narrow-Bold.inf +26 -0
- data/fonts/Helvetica-Narrow-BoldOblique.afm +1439 -0
- data/fonts/Helvetica-Narrow-BoldOblique.inf +26 -0
- data/fonts/Helvetica-Narrow-Oblique.afm +1556 -0
- data/fonts/Helvetica-Narrow-Oblique.inf +26 -0
- data/fonts/Helvetica-Narrow.afm +1556 -0
- data/fonts/Helvetica-Narrow.inf +26 -0
- data/fonts/Helvetica-Oblique.afm +3051 -0
- data/fonts/Helvetica-Oblique.inf +26 -0
- data/fonts/Helvetica.afm +3051 -0
- data/fonts/Helvetica.inf +26 -0
- data/fonts/LetterGothic-Bold.afm +443 -0
- data/fonts/LetterGothic-Bold.inf +26 -0
- data/fonts/LetterGothic-BoldSlanted.afm +443 -0
- data/fonts/LetterGothic-BoldSlanted.inf +26 -0
- data/fonts/LetterGothic-Slanted.afm +443 -0
- data/fonts/LetterGothic-Slanted.inf +26 -0
- data/fonts/LetterGothic.afm +443 -0
- data/fonts/LetterGothic.inf +26 -0
- data/fonts/LubalinGraph-Book.afm +351 -0
- data/fonts/LubalinGraph-Book.inf +25 -0
- data/fonts/LubalinGraph-BookOblique.afm +351 -0
- data/fonts/LubalinGraph-BookOblique.inf +25 -0
- data/fonts/LubalinGraph-Demi.afm +351 -0
- data/fonts/LubalinGraph-Demi.inf +25 -0
- data/fonts/LubalinGraph-DemiOblique.afm +351 -0
- data/fonts/LubalinGraph-DemiOblique.inf +25 -0
- data/fonts/Marigold.afm +491 -0
- data/fonts/Marigold.inf +27 -0
- data/fonts/MonaLisa-Recut.afm +663 -0
- data/fonts/MonaLisa-Recut.inf +27 -0
- data/fonts/NewCenturySchlbk-Bold.afm +886 -0
- data/fonts/NewCenturySchlbk-Bold.inf +25 -0
- data/fonts/NewCenturySchlbk-BoldItalic.afm +1521 -0
- data/fonts/NewCenturySchlbk-BoldItalic.inf +26 -0
- data/fonts/NewCenturySchlbk-Italic.afm +1113 -0
- data/fonts/NewCenturySchlbk-Italic.inf +26 -0
- data/fonts/NewCenturySchlbk-Roman.afm +1067 -0
- data/fonts/NewCenturySchlbk-Roman.inf +26 -0
- data/fonts/Optima-Bold.afm +515 -0
- data/fonts/Optima-Bold.inf +27 -0
- data/fonts/Optima-BoldItalic.afm +712 -0
- data/fonts/Optima-BoldItalic.inf +26 -0
- data/fonts/Optima-Italic.afm +737 -0
- data/fonts/Optima-Italic.inf +26 -0
- data/fonts/Optima.afm +501 -0
- data/fonts/Optima.inf +27 -0
- data/fonts/Palatino-Bold.afm +675 -0
- data/fonts/Palatino-Bold.inf +26 -0
- data/fonts/Palatino-BoldItalic.afm +702 -0
- data/fonts/Palatino-BoldItalic.inf +26 -0
- data/fonts/Palatino-Italic.afm +700 -0
- data/fonts/Palatino-Italic.inf +26 -0
- data/fonts/Palatino-Roman.afm +718 -0
- data/fonts/Palatino-Roman.inf +26 -0
- data/fonts/StempelGaramond-Bold.afm +412 -0
- data/fonts/StempelGaramond-Bold.inf +27 -0
- data/fonts/StempelGaramond-BoldItalic.afm +413 -0
- data/fonts/StempelGaramond-BoldItalic.inf +27 -0
- data/fonts/StempelGaramond-Italic.afm +413 -0
- data/fonts/StempelGaramond-Italic.inf +27 -0
- data/fonts/StempelGaramond-Roman.afm +412 -0
- data/fonts/StempelGaramond-Roman.inf +27 -0
- data/fonts/Symbol.afm +213 -0
- data/fonts/Symbol.inf +27 -0
- data/fonts/Times-Bold.afm +2588 -0
- data/fonts/Times-Bold.inf +26 -0
- data/fonts/Times-BoldItalic.afm +2384 -0
- data/fonts/Times-BoldItalic.inf +26 -0
- data/fonts/Times-Italic.afm +2667 -0
- data/fonts/Times-Italic.inf +26 -0
- data/fonts/Times-Roman.afm +2419 -0
- data/fonts/Times-Roman.inf +26 -0
- data/fonts/Univers-Bold.afm +712 -0
- data/fonts/Univers-Bold.inf +27 -0
- data/fonts/Univers-BoldOblique.afm +712 -0
- data/fonts/Univers-BoldOblique.inf +27 -0
- data/fonts/Univers-Condensed.afm +403 -0
- data/fonts/Univers-Condensed.inf +27 -0
- data/fonts/Univers-CondensedOblique.afm +403 -0
- data/fonts/Univers-CondensedOblique.inf +27 -0
- data/fonts/Univers-Light.afm +737 -0
- data/fonts/Univers-Light.inf +27 -0
- data/fonts/Univers-LightOblique.afm +737 -0
- data/fonts/Univers-LightOblique.inf +27 -0
- data/fonts/Univers-Oblique.afm +656 -0
- data/fonts/Univers-Oblique.inf +27 -0
- data/fonts/Univers.afm +656 -0
- data/fonts/Univers.inf +27 -0
- data/fonts/ZapfChancery-MediumItalic.afm +842 -0
- data/fonts/ZapfChancery-MediumItalic.inf +26 -0
- data/fonts/ZapfDingbats.afm +225 -0
- data/fonts/ZapfDingbats.inf +26 -0
- data/lib/epdfafm.rb +334 -0
- data/lib/epdfdw.rb +710 -0
- data/lib/epdfk.rb +3142 -0
- data/lib/epdfo.rb +882 -0
- data/lib/epdfpw.rb +1749 -0
- data/lib/epdfs.rb +101 -0
- data/lib/epdfsw.rb +267 -0
- data/lib/epdft.rb +145 -0
- data/lib/epdftt.rb +458 -0
- data/test/pdf_tests.rb +16 -0
- data/test/test.rb +816 -0
- data/test/test_epdfafm.rb +202 -0
- data/test/test_epdfdw.rb +369 -0
- data/test/test_epdfk.rb +47 -0
- data/test/test_epdfo.rb +762 -0
- data/test/test_epdfpw.rb +129 -0
- data/test/test_epdfs.rb +54 -0
- data/test/test_epdfsw.rb +314 -0
- data/test/test_epdft.rb +198 -0
- data/test/test_epdftt.rb +34 -0
- data/test/test_helpers.rb +18 -0
- data/test/testimg.jpg +0 -0
- metadata +247 -0
data/test/test_epdfo.rb
ADDED
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# Created by Brent Rowland on 2007-07-14.
|
|
4
|
+
# Copyright (c) 2007, Eidetic Software. All rights reserved.
|
|
5
|
+
|
|
6
|
+
$: << File.dirname(__FILE__) + '/../lib'
|
|
7
|
+
require 'test/unit'
|
|
8
|
+
require 'epdfo'
|
|
9
|
+
|
|
10
|
+
include EideticPDF::PdfObjects
|
|
11
|
+
|
|
12
|
+
class HeaderTestCases < Test::Unit::TestCase
|
|
13
|
+
def setup
|
|
14
|
+
@header = Header.new
|
|
15
|
+
@header11 = Header.new(1.1)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_to_s
|
|
19
|
+
assert_equal("%PDF-1.3\n", @header.to_s)
|
|
20
|
+
assert_equal("%PDF-1.1\n", @header11.to_s)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class IndirectObjectRefTestCases < Test::Unit::TestCase
|
|
25
|
+
def test_to_s
|
|
26
|
+
io = IndirectObject.new(1,0)
|
|
27
|
+
ior = IndirectObjectRef.new(io)
|
|
28
|
+
assert_equal("1 0 R ", ior.to_s)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class IndirectObjectTestCases < Test::Unit::TestCase
|
|
33
|
+
def setup
|
|
34
|
+
@io = IndirectObject.new(1,0)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_header
|
|
38
|
+
assert_equal("1 0 obj\n", @io.header)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_body
|
|
42
|
+
assert_equal('', @io.body)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_footer
|
|
46
|
+
assert_equal("endobj\n", @io.footer)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_to_s
|
|
50
|
+
assert_equal("1 0 obj\n" + "endobj\n", @io.to_s)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class PdfBooleanTestCases < Test::Unit::TestCase
|
|
55
|
+
def setup
|
|
56
|
+
@t = PdfBoolean.new(true)
|
|
57
|
+
@f = PdfBoolean.new(false)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_to_s
|
|
61
|
+
assert_equal('true ', @t.to_s)
|
|
62
|
+
assert_equal('false ', @f.to_s)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class PdfIntegerTestCases < Test::Unit::TestCase
|
|
67
|
+
def test_to_s
|
|
68
|
+
seven = PdfInteger.new(7)
|
|
69
|
+
assert_equal('7 ', seven.to_s)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_ary1
|
|
73
|
+
a = PdfInteger.ary([1, 2, 3])
|
|
74
|
+
assert_equal("[1 2 3 ] ", a.to_s)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_ary2
|
|
78
|
+
a = PdfInteger.ary([1, 2, [3, 4]])
|
|
79
|
+
assert_equal("[1 2 [3 4 ] ] ", a.to_s)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
class PdfRealTestCases < Test::Unit::TestCase
|
|
84
|
+
def test_to_s
|
|
85
|
+
five_five = PdfReal.new(5.5)
|
|
86
|
+
assert_equal('5.5 ', five_five.to_s)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
class PdfStringTestCases < Test::Unit::TestCase
|
|
91
|
+
def test_to_s
|
|
92
|
+
string = PdfString.new('a\b(cd)')
|
|
93
|
+
assert_equal(%q/(a\\\\b\(cd\)) /, string.to_s)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_escape
|
|
97
|
+
assert_equal('a\\\\b\(cd\)', PdfString.escape('a\\b(cd)'))
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class PdfNameTestCases < Test::Unit::TestCase
|
|
102
|
+
def test_to_s
|
|
103
|
+
name = PdfName.new('name')
|
|
104
|
+
assert_equal('/name ', name.to_s)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
class PdfArrayTestCases < Test::Unit::TestCase
|
|
109
|
+
def setup
|
|
110
|
+
@ary1 = PdfArray.new([1, 2, 3, 4, 5])
|
|
111
|
+
@ary2 = PdfArray.new([1, 2, 3, 4, 5], 3)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_to_s
|
|
115
|
+
assert_equal("[12345] ", @ary1.to_s)
|
|
116
|
+
assert_equal("[123\n45] ", @ary2.to_s)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
class PdfDictionaryTestCases < Test::Unit::TestCase
|
|
121
|
+
def test_to_s
|
|
122
|
+
h = {
|
|
123
|
+
PdfName.new('foo') => PdfString.new('bar'),
|
|
124
|
+
PdfName.new('baz') => PdfInteger.new(7)
|
|
125
|
+
}
|
|
126
|
+
d = PdfDictionary.new(h)
|
|
127
|
+
assert_equal("<<\n/baz 7 \n/foo (bar) \n>>\n", d.to_s)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
class PdfDictionaryObjectTestCases < Test::Unit::TestCase
|
|
132
|
+
def test_body
|
|
133
|
+
h = {
|
|
134
|
+
'foo' => PdfString.new('bar'),
|
|
135
|
+
'baz' => PdfInteger.new(7)
|
|
136
|
+
}
|
|
137
|
+
pdo = PdfDictionaryObject.new(1,0,h)
|
|
138
|
+
assert_equal("<<\n/baz 7 \n/foo (bar) \n>>\n", pdo.body)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
class PdfStreamTestCases < Test::Unit::TestCase
|
|
143
|
+
def setup
|
|
144
|
+
@ps = PdfStream.new(1,0,'test')
|
|
145
|
+
# @ps.length = 4
|
|
146
|
+
@ps.filter = 'bogus'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_length
|
|
150
|
+
assert_equal(PdfInteger.new(4), @ps.dictionary['Length'])
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def test_filter
|
|
154
|
+
assert_equal(PdfName.new('bogus'), @ps.dictionary['Filter'])
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def test_body
|
|
158
|
+
assert_equal("<<\n/Filter /bogus \n/Length 4 \n>>\nstream\ntestendstream\n", @ps.body)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def test_to_s
|
|
162
|
+
assert_equal("1 0 obj\n<<\n/Filter /bogus \n/Length 4 \n>>\nstream\ntestendstream\nendobj\n", @ps.to_s)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
class PdfNullTestCases < Test::Unit::TestCase
|
|
167
|
+
def test_to_s
|
|
168
|
+
null = PdfNull.new
|
|
169
|
+
assert_equal("null ", null.to_s)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
class InUseXRefEntryTestCases < Test::Unit::TestCase
|
|
174
|
+
def test_to_s
|
|
175
|
+
entry = InUseXRefEntry.new(500,0)
|
|
176
|
+
assert_equal("0000000500 00000 n\n", entry.to_s)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
class FreeXRefEntryTestCases < Test::Unit::TestCase
|
|
181
|
+
def test_to_s
|
|
182
|
+
entry = FreeXRefEntry.new(1,0)
|
|
183
|
+
assert_equal("0000000001 00000 f\n", entry.to_s)
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
class XRefSubSectionTestCases < Test::Unit::TestCase
|
|
188
|
+
def setup
|
|
189
|
+
@sub_section = XRefSubSection.new
|
|
190
|
+
@sub_section << InUseXRefEntry.new(0,0)
|
|
191
|
+
@sub_section << InUseXRefEntry.new(100,1)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def test_to_s
|
|
195
|
+
assert_equal("0 3\n0000000000 65535 f\n0000000000 00000 n\n0000000100 00001 n\n", @sub_section.to_s)
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
class XRefTableTestCases < Test::Unit::TestCase
|
|
200
|
+
def setup
|
|
201
|
+
@table = XRefTable.new
|
|
202
|
+
@sub_section = XRefSubSection.new
|
|
203
|
+
@sub_section << InUseXRefEntry.new(0,0)
|
|
204
|
+
@sub_section << InUseXRefEntry.new(100,1)
|
|
205
|
+
@table << @sub_section
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def test_to_s
|
|
209
|
+
assert_equal("xref\n0 3\n0000000000 65535 f\n0000000000 00000 n\n0000000100 00001 n\n", @table.to_s)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
class BodyTestCases < Test::Unit::TestCase
|
|
214
|
+
def setup
|
|
215
|
+
@io_int = IndirectObject.new(1,0,PdfInteger.new(7))
|
|
216
|
+
@io_str = IndirectObject.new(2,0,PdfString.new("Hello"))
|
|
217
|
+
@body = Body.new
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def test_write_and_xref
|
|
221
|
+
@body << @io_int << @io_str
|
|
222
|
+
s = ''
|
|
223
|
+
sub_section = XRefSubSection.new
|
|
224
|
+
@body.write_and_xref(s, sub_section)
|
|
225
|
+
assert_equal(@io_int.to_s + @io_str.to_s, s)
|
|
226
|
+
assert_equal("0 3\n0000000000 65535 f\n0000000000 00000 n\n0000000018 00000 n\n", sub_section.to_s)
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
class PdfCatalogTestCases < Test::Unit::TestCase
|
|
231
|
+
def setup
|
|
232
|
+
@pages = PdfPages.new(1, 0)
|
|
233
|
+
@outlines = PdfOutlines.new(2, 0)
|
|
234
|
+
@cat = PdfCatalog.new(3, 0, :use_none, @pages, @outlines)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def test_to_s
|
|
238
|
+
assert_equal("3 0 obj\n<<\n/Outlines 2 0 R \n/PageMode /UseNone \n/Pages 1 0 R \n/Type /Catalog \n>>\nendobj\n", @cat.to_s)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
class TrailerTestCases < Test::Unit::TestCase
|
|
243
|
+
def setup
|
|
244
|
+
@trailer = Trailer.new
|
|
245
|
+
@trailer.xref_table_start = 0
|
|
246
|
+
@trailer.xref_table_size = 3
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def test_xref_table_size
|
|
250
|
+
assert_equal(3, @trailer.xref_table_size)
|
|
251
|
+
assert_equal(3, @trailer['Size'].value)
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def test_to_s
|
|
255
|
+
assert_equal("trailer\n<<\n/Size 3 \n>>\nstartxref\n0\n%%EOF\n", @trailer.to_s)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
class RectangleTestCases < Test::Unit::TestCase
|
|
260
|
+
def setup
|
|
261
|
+
@rect = Rectangle.new(1,2,3,4)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def test_attributes
|
|
265
|
+
assert_equal(1, @rect.x1)
|
|
266
|
+
assert_equal(2, @rect.y1)
|
|
267
|
+
assert_equal(3, @rect.x2)
|
|
268
|
+
assert_equal(4, @rect.y2)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def test_to_s
|
|
272
|
+
assert_equal("[1 2 3 4 ] ", @rect.to_s)
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
module FontFactory
|
|
277
|
+
def make_font_descriptor
|
|
278
|
+
PdfFontDescriptor.new(100, 0,
|
|
279
|
+
'ArialMT', 32, [-665, -325, 2029, 1006], 0, 0, 0, 0,
|
|
280
|
+
723, 525,
|
|
281
|
+
905, -212, 33,
|
|
282
|
+
2000, 0)
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
class PdfFontTestCases < Test::Unit::TestCase
|
|
287
|
+
include FontFactory
|
|
288
|
+
|
|
289
|
+
def setup
|
|
290
|
+
@widths = PdfArray.new([1, 3, 5, 7])
|
|
291
|
+
@io_widths = IndirectObject.new(2, 0, @widths)
|
|
292
|
+
@font_descriptor = make_font_descriptor
|
|
293
|
+
@font = PdfFont.new(1, 0, 'TrueType', 'ArialMT', 32, 169, @io_widths, @font_descriptor)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def test_to_s
|
|
297
|
+
expected = "1 0 obj\n" <<
|
|
298
|
+
"<<\n" <<
|
|
299
|
+
"/BaseFont /ArialMT \n" <<
|
|
300
|
+
"/FirstChar 32 \n" <<
|
|
301
|
+
"/FontDescriptor 100 0 R \n" <<
|
|
302
|
+
"/LastChar 169 \n" <<
|
|
303
|
+
"/Subtype /TrueType \n" <<
|
|
304
|
+
"/Type /Font \n" <<
|
|
305
|
+
"/Widths 2 0 R \n" <<
|
|
306
|
+
">>\n" <<
|
|
307
|
+
"endobj\n"
|
|
308
|
+
assert_equal(expected, @font.to_s)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def test_encoding=
|
|
312
|
+
@font.encoding = 'WinAnsiEncoding'
|
|
313
|
+
assert_equal(PdfName.new('WinAnsiEncoding'), @font.dictionary['Encoding'])
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
class PdfFontDescriptorTestCases < Test::Unit::TestCase
|
|
318
|
+
include FontFactory
|
|
319
|
+
|
|
320
|
+
def setup
|
|
321
|
+
@font_descriptor = make_font_descriptor
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def test_to_s
|
|
325
|
+
expected = "100 0 obj\n" <<
|
|
326
|
+
"<<\n" <<
|
|
327
|
+
"/Ascent 905 \n" <<
|
|
328
|
+
"/AvgWidth 0 \n" <<
|
|
329
|
+
"/CapHeight 723 \n" <<
|
|
330
|
+
"/Descent -212 \n" <<
|
|
331
|
+
"/Flags 32 \n" <<
|
|
332
|
+
"/FontBBox [-665 -325 2029 1006 ] \n" <<
|
|
333
|
+
"/FontName /ArialMT \n" <<
|
|
334
|
+
"/ItalicAngle 0.0 \n" <<
|
|
335
|
+
"/Leading 33 \n" <<
|
|
336
|
+
"/MaxWidth 2000 \n" <<
|
|
337
|
+
"/MissingWidth 0 \n" <<
|
|
338
|
+
"/StemH 0 \n" <<
|
|
339
|
+
"/StemV 0 \n" <<
|
|
340
|
+
"/Type /FontDescriptor \n" <<
|
|
341
|
+
"/XHeight 525 \n" <<
|
|
342
|
+
">>\n" <<
|
|
343
|
+
"endobj\n"
|
|
344
|
+
assert_equal(expected, @font_descriptor.to_s)
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
class PdfFontEncodingTestCases < Test::Unit::TestCase
|
|
349
|
+
def setup
|
|
350
|
+
differences = PdfArray.new([PdfInteger.new(32), PdfName.new('space')])
|
|
351
|
+
@font_encoding = PdfFontEncoding.new(1, 0, "MacRomanEncoding", differences)
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def test_to_s
|
|
355
|
+
expected = "1 0 obj\n" <<
|
|
356
|
+
"<<\n" <<
|
|
357
|
+
"/BaseEncoding /MacRomanEncoding \n" <<
|
|
358
|
+
"/Differences [32 /space ] \n" <<
|
|
359
|
+
"/Type /Encoding \n" <<
|
|
360
|
+
">>\n" <<
|
|
361
|
+
"endobj\n"
|
|
362
|
+
assert_equal(expected, @font_encoding.to_s)
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
class PdfXObjectTestCases < Test::Unit::TestCase
|
|
367
|
+
def test_initialize
|
|
368
|
+
xobj = PdfXObject.new(1,0)
|
|
369
|
+
assert_equal(PdfName.new('XObject'), xobj.dictionary['Type'])
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
class PdfImageTestCases < Test::Unit::TestCase
|
|
374
|
+
def setup
|
|
375
|
+
@image = PdfImage.new(1,0,'test')
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
def test_initialize
|
|
379
|
+
assert_equal(PdfName.new('XObject'), @image.dictionary['Type'])
|
|
380
|
+
assert_equal(PdfName.new('Image'), @image.dictionary['Subtype'])
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def test_body
|
|
384
|
+
assert_equal("<<\n/Length 4 \n/Subtype /Image \n/Type /XObject \n>>\nstream\ntestendstream\n", @image.body)
|
|
385
|
+
assert_equal(PdfInteger.new(4), @image.dictionary['Length'])
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def test_filter=
|
|
389
|
+
@image.filter = 'ASCIIHexDecode'
|
|
390
|
+
assert_equal(PdfName.new('ASCIIHexDecode'), @image.dictionary['Filter'])
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def test_filters=
|
|
394
|
+
filters = PdfArray.new ['ASCII85Decode', 'LZWDecode'].map { |s| PdfName.new(s) }
|
|
395
|
+
@image.filters = filters
|
|
396
|
+
assert_equal(filters, @image.dictionary['Filter'])
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def test_width
|
|
400
|
+
@image.width = 320
|
|
401
|
+
assert_equal(320, @image.width)
|
|
402
|
+
assert_equal(PdfInteger.new(320), @image.dictionary['Width'])
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def test_height
|
|
406
|
+
@image.height = 200
|
|
407
|
+
assert_equal(200, @image.height)
|
|
408
|
+
assert_equal(PdfInteger.new(200), @image.dictionary['Height'])
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def test_bits_per_component=
|
|
412
|
+
@image.bits_per_component = 8
|
|
413
|
+
assert_equal(PdfInteger.new(8), @image.dictionary['BitsPerComponent'])
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
def test_color_space=
|
|
417
|
+
@image.color_space = 'DeviceCMYK'
|
|
418
|
+
assert_equal(PdfName.new('DeviceCMYK'), @image.dictionary['ColorSpace'])
|
|
419
|
+
# todo: test other types of values, such as indirect objects
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
def test_decode=
|
|
423
|
+
decode = PdfArray.new [1, 0].map { |i| PdfInteger.new(i )}
|
|
424
|
+
@image.decode = decode
|
|
425
|
+
assert_equal(decode, @image.dictionary['Decode'])
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def test_interpolate=
|
|
429
|
+
@image.interpolate = true
|
|
430
|
+
assert_equal(PdfBoolean.new(true), @image.dictionary['Interpolate'])
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def test_image_mask=
|
|
434
|
+
@image.image_mask = false
|
|
435
|
+
assert_equal(PdfBoolean.new(false), @image.dictionary['ImageMask'])
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
def test_intent=
|
|
439
|
+
@image.intent = 'AbsoluteColorimetric'
|
|
440
|
+
assert_equal(PdfName.new('AbsoluteColorimetric'), @image.dictionary['Intent'])
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
class PdfAnnotTestCases < Test::Unit::TestCase
|
|
445
|
+
def setup
|
|
446
|
+
@rect = Rectangle.new(1,2,3,4)
|
|
447
|
+
@annot = PdfAnnot.new(1, 0, 'Text', @rect)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def test_initialize
|
|
451
|
+
assert_equal(1, @annot.seq)
|
|
452
|
+
assert_equal(0, @annot.gen)
|
|
453
|
+
assert_equal(PdfName.new('Annot'), @annot.dictionary['Type'])
|
|
454
|
+
assert_equal(PdfName.new('Text'), @annot.dictionary['Subtype'])
|
|
455
|
+
assert_equal(@rect, @annot.dictionary['Rect'])
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def test_border=
|
|
459
|
+
border = [0, 0, 1]
|
|
460
|
+
@annot.border = border
|
|
461
|
+
assert_equal(PdfInteger.ary(border), @annot.dictionary['Border'])
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
def test_color=
|
|
465
|
+
color = [0.2, 0.4, 0.6]
|
|
466
|
+
@annot.color = color
|
|
467
|
+
assert_equal(PdfReal.ary(color), @annot.dictionary['C'])
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
def test_title=
|
|
471
|
+
@annot.title = 'Joe'
|
|
472
|
+
assert_equal(PdfString.new('Joe'), @annot.dictionary['T'])
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
def test_mod_date=
|
|
476
|
+
t = Time.local(2007, 9, 8, 14, 30, 0, 0)
|
|
477
|
+
@annot.mod_date = t
|
|
478
|
+
assert_equal(PdfString.new('20070908143000'), @annot.dictionary['M'])
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
def test_flags=
|
|
482
|
+
@annot.flags = 0
|
|
483
|
+
assert_equal(PdfInteger.new(0), @annot.dictionary['F'])
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
def test_highlight=
|
|
487
|
+
@annot.highlight = :none
|
|
488
|
+
assert_equal(PdfName.new('N'), @annot.dictionary['H'])
|
|
489
|
+
@annot.highlight = :invert
|
|
490
|
+
assert_equal(PdfName.new('I'), @annot.dictionary['H'])
|
|
491
|
+
@annot.highlight = :outline
|
|
492
|
+
assert_equal(PdfName.new('O'), @annot.dictionary['H'])
|
|
493
|
+
@annot.highlight = :push
|
|
494
|
+
assert_equal(PdfName.new('P'), @annot.dictionary['H'])
|
|
495
|
+
|
|
496
|
+
@annot.highlight = 'N'
|
|
497
|
+
assert_equal(PdfName.new('N'), @annot.dictionary['H'])
|
|
498
|
+
@annot.highlight = 'I'
|
|
499
|
+
assert_equal(PdfName.new('I'), @annot.dictionary['H'])
|
|
500
|
+
@annot.highlight = 'O'
|
|
501
|
+
assert_equal(PdfName.new('O'), @annot.dictionary['H'])
|
|
502
|
+
@annot.highlight = 'P'
|
|
503
|
+
assert_equal(PdfName.new('P'), @annot.dictionary['H'])
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
def test_border_style=
|
|
507
|
+
border_style = {
|
|
508
|
+
'Type' => PdfName.new('Border'),
|
|
509
|
+
'W' => PdfInteger.new(1),
|
|
510
|
+
'S' => PdfName.new('D'),
|
|
511
|
+
'D' => PdfInteger.ary([3, 2])
|
|
512
|
+
}
|
|
513
|
+
@annot.border_style = border_style
|
|
514
|
+
assert_equal(PdfDictionary.new(border_style).to_s, @annot.dictionary['BS'].to_s)
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
def test_appearance_dictionary=
|
|
518
|
+
io = IndirectObject.new(1,0)
|
|
519
|
+
appearance = { 'N' => io.reference_object }
|
|
520
|
+
@annot.appearance_dictionary = appearance
|
|
521
|
+
assert_equal("<<\n/N 1 0 R \n>>\n", @annot.dictionary['AP'].to_s)
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
def test_appearance_state=
|
|
525
|
+
@annot.appearance_state = 'Yes'
|
|
526
|
+
assert_equal(PdfName.new('Yes'), @annot.dictionary['AS'])
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
class PdfTextAnnotTestCases < Test::Unit::TestCase
|
|
531
|
+
def setup
|
|
532
|
+
@rect = Rectangle.new(1,2,3,4)
|
|
533
|
+
@annot = PdfTextAnnot.new(1, 0, @rect, 'Hello')
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
def test_initialize
|
|
537
|
+
assert_equal(PdfName.new('Text'), @annot.dictionary['Subtype'])
|
|
538
|
+
assert_equal(PdfString.new('Hello'), @annot.dictionary['Contents'])
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
def test_open=
|
|
542
|
+
@annot.open = true
|
|
543
|
+
assert_equal(PdfBoolean.new(true), @annot.dictionary['Open'])
|
|
544
|
+
@annot.open = false
|
|
545
|
+
assert_equal(PdfBoolean.new(false), @annot.dictionary['Open'])
|
|
546
|
+
end
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
#class PdfLinkAnnotTestCases < Test::Unit::TestCase
|
|
550
|
+
#end
|
|
551
|
+
|
|
552
|
+
#class PdfMovieAnnotTestCases < Test::Unit::TestCase
|
|
553
|
+
#end
|
|
554
|
+
|
|
555
|
+
class PdfSoundAnnotTestCases < Test::Unit::TestCase
|
|
556
|
+
def test_initialize
|
|
557
|
+
rect = Rectangle.new(1,2,3,4)
|
|
558
|
+
stream = PdfStream.new(1, 0, 'test')
|
|
559
|
+
sound = PdfSoundAnnot.new(2, 0, rect, stream)
|
|
560
|
+
assert_equal(PdfName.new('Sound'), sound.dictionary['Subtype'])
|
|
561
|
+
assert_equal(stream, sound.dictionary['Sound'])
|
|
562
|
+
end
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
#class PdfURIActionTestCases < Test::Unit::TestCase
|
|
566
|
+
#end
|
|
567
|
+
|
|
568
|
+
#class PdfAnnotBorderTestCases < Test::Unit::TestCase
|
|
569
|
+
#end
|
|
570
|
+
|
|
571
|
+
class PdfResourcesTestCases < Test::Unit::TestCase
|
|
572
|
+
def setup
|
|
573
|
+
@res = PdfResources.new(1,0)
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
def test_proc_set=
|
|
577
|
+
a = PdfName.ary ['PDF','Text','ImageB','ImageC']
|
|
578
|
+
@res.proc_set = a
|
|
579
|
+
assert_equal(a, @res.dictionary['ProcSet'])
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
def test_fonts
|
|
583
|
+
io = IndirectObject.new(2,0)
|
|
584
|
+
@res.fonts['F1'] = io.reference_object
|
|
585
|
+
assert_equal("1 0 obj\n<<\n/Font <<\n/F1 2 0 R \n>>\n\n>>\nendobj\n", @res.to_s)
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
def test_x_objects
|
|
589
|
+
io = IndirectObject.new(2,0)
|
|
590
|
+
@res.x_objects['Im1'] = io.reference_object
|
|
591
|
+
assert_equal("1 0 obj\n<<\n/XObject <<\n/Im1 2 0 R \n>>\n\n>>\nendobj\n", @res.to_s)
|
|
592
|
+
end
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
class PdfPageBaseTestCases < Test::Unit::TestCase
|
|
596
|
+
def setup
|
|
597
|
+
@io = IndirectObject.new(1, 0)
|
|
598
|
+
@base = PdfPageBase.new(2, 0, @io)
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
def test_initialize
|
|
602
|
+
assert_equal('1 0 R ', @base.dictionary['Parent'].to_s)
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
def test_media_box=
|
|
606
|
+
r = Rectangle.new(1, 2, 3, 4)
|
|
607
|
+
@base.media_box = r
|
|
608
|
+
assert_equal('[1 2 3 4 ] ', @base.dictionary['MediaBox'].to_s)
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
def test_resources=
|
|
612
|
+
resources = PdfResources.new(3, 0)
|
|
613
|
+
@base.resources = resources
|
|
614
|
+
assert_equal('3 0 R ', @base.dictionary['Resources'].to_s)
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
def test_crop_box=
|
|
618
|
+
r = Rectangle.new(1, 2, 3, 4)
|
|
619
|
+
@base.crop_box = r
|
|
620
|
+
assert_equal('[1 2 3 4 ] ', @base.dictionary['CropBox'].to_s)
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
def test_rotate=
|
|
624
|
+
@base.rotate = 90
|
|
625
|
+
assert_equal(PdfInteger.new(90), @base.dictionary['Rotate'])
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
def test_duration=
|
|
629
|
+
@base.duration = 5
|
|
630
|
+
assert_equal('5 ', @base.dictionary['Dur'].to_s)
|
|
631
|
+
@base.duration = 6.5
|
|
632
|
+
assert_equal('6.5 ', @base.dictionary['Dur'].to_s)
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
def test_hidden=
|
|
636
|
+
@base.hidden = true
|
|
637
|
+
assert_equal('true ', @base.dictionary['Hid'].to_s)
|
|
638
|
+
end
|
|
639
|
+
|
|
640
|
+
def test_transition=
|
|
641
|
+
t = {
|
|
642
|
+
'Type' => PdfName.new('Trans'),
|
|
643
|
+
'D' => PdfReal.new(3.5),
|
|
644
|
+
'S' => PdfName.new('Split'),
|
|
645
|
+
'Dm' => PdfName.new('V'),
|
|
646
|
+
'M' => PdfName.new('O')
|
|
647
|
+
}
|
|
648
|
+
@base.transition = t
|
|
649
|
+
assert_equal("<<\n/D 3.5 \n/Dm /V \n/M /O \n/S /Split \n/Type /Trans \n>>\n", @base.dictionary['Trans'].to_s)
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
def test_additional_actions=
|
|
653
|
+
aa = { 'Foo' => PdfName.new('Bar') }
|
|
654
|
+
@base.additional_actions = aa
|
|
655
|
+
assert_equal("<<\n/Foo /Bar \n>>\n", @base.dictionary['AA'].to_s)
|
|
656
|
+
end
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
class PdfPageTestCases < Test::Unit::TestCase
|
|
660
|
+
def setup
|
|
661
|
+
pages = PdfPages.new(1, 0)
|
|
662
|
+
@page = PdfPage.new(2, 0, pages)
|
|
663
|
+
@stream = PdfStream.new(3, 0, 'test')
|
|
664
|
+
@page.contents << @stream
|
|
665
|
+
end
|
|
666
|
+
|
|
667
|
+
def test_initialize
|
|
668
|
+
assert_equal(PdfName.new('Page'), @page.dictionary['Type'])
|
|
669
|
+
end
|
|
670
|
+
|
|
671
|
+
def test_body
|
|
672
|
+
assert_equal("<<\n/Contents 3 0 R \n/Parent 1 0 R \n/Type /Page \n>>\n", @page.body)
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
def test_contents
|
|
676
|
+
@page.body # Cause dictionary to be updated.
|
|
677
|
+
assert_equal(@stream.reference_object, @page.dictionary['Contents'])
|
|
678
|
+
|
|
679
|
+
@page.contents << @stream
|
|
680
|
+
@page.body
|
|
681
|
+
assert_equal(PdfArray.new([@stream.reference_object, @stream.reference_object]), @page.dictionary['Contents'])
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
# xxx these methods to be implemented if necessary
|
|
685
|
+
def test_thumb=
|
|
686
|
+
@page.thumb = @stream
|
|
687
|
+
assert_equal(@stream.reference_object, @page.dictionary['Thumb'])
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
def test_annots=
|
|
691
|
+
rect = Rectangle.new(1,2,3,4)
|
|
692
|
+
annot = PdfTextAnnot.new(4, 0, rect, 'Hello')
|
|
693
|
+
@page.annots = [annot]
|
|
694
|
+
annots = PdfArray.new([annot.reference_object])
|
|
695
|
+
assert_equal(annots, @page.dictionary['Annots'])
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
def test_beads=
|
|
699
|
+
b1 = IndirectObject.new(4, 0)
|
|
700
|
+
b2 = IndirectObject.new(5, 0)
|
|
701
|
+
@page.beads = [b1, b2]
|
|
702
|
+
assert_equal(PdfArray.new([b1.reference_object, b2.reference_object]), @page.dictionary['B'])
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
|
|
706
|
+
class PdfPagesTestCases < Test::Unit::TestCase
|
|
707
|
+
def setup
|
|
708
|
+
@pages = PdfPages.new(1, 0)
|
|
709
|
+
@page = PdfPage.new(2, 0, @pages)
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
def test_initialize
|
|
713
|
+
assert_equal(PdfName.new('Pages'), @pages.dictionary['Type'])
|
|
714
|
+
assert_equal([], @pages.kids)
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
def test_to_s
|
|
718
|
+
@pages.kids << @page
|
|
719
|
+
assert_equal("1 0 obj\n<<\n/Count 1 \n/Kids [2 0 R ] \n/Type /Pages \n>>\nendobj\n", @pages.to_s)
|
|
720
|
+
end
|
|
721
|
+
end
|
|
722
|
+
|
|
723
|
+
class PdfOutlinesTestCases < Test::Unit::TestCase
|
|
724
|
+
def setup
|
|
725
|
+
@outlines = PdfOutlines.new(1, 0)
|
|
726
|
+
end
|
|
727
|
+
|
|
728
|
+
def test_initialize
|
|
729
|
+
assert_equal(PdfName.new('Outlines'), @outlines.dictionary['Type'])
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
def test_to_s
|
|
733
|
+
assert_equal("1 0 obj\n<<\n/Count 0 \n/Type /Outlines \n>>\nendobj\n", @outlines.to_s)
|
|
734
|
+
end
|
|
735
|
+
end
|
|
736
|
+
|
|
737
|
+
class PdfFileTestCases < Test::Unit::TestCase
|
|
738
|
+
def setup
|
|
739
|
+
@file = PdfFile.new
|
|
740
|
+
end
|
|
741
|
+
|
|
742
|
+
def test_initialize
|
|
743
|
+
assert_not_nil(@file.body)
|
|
744
|
+
assert_not_nil(@file.trailer)
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
def test_header
|
|
748
|
+
assert_equal("%PDF-1.3\n", @file.header.to_s)
|
|
749
|
+
end
|
|
750
|
+
|
|
751
|
+
def test_body
|
|
752
|
+
assert_equal("", @file.body.to_s)
|
|
753
|
+
end
|
|
754
|
+
|
|
755
|
+
def test_trailer
|
|
756
|
+
assert_equal("trailer\n<<\n>>\nstartxref\n\n%%EOF\n", @file.trailer.to_s)
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
def test_to_s
|
|
760
|
+
assert_equal("%PDF-1.3\nxref\n0 1\n0000000000 65535 f\ntrailer\n<<\n/Size 1 \n>>\nstartxref\n9\n%%EOF\n", @file.to_s)
|
|
761
|
+
end
|
|
762
|
+
end
|