@@ -40,12 +40,7 @@ source product.
40
40
For more information, please contact iText Software Corp. at this
41
41
42
42
*/
43
- using System ;
44
- using iText . Kernel . Colors ;
45
- using iText . Kernel . Font ;
46
43
using iText . Kernel . Pdf ;
47
- using iText . Kernel . Pdf . Colorspace ;
48
- using iText . Kernel . Pdf . Xobject ;
49
44
using iText . Pdfa ;
50
45
using iText . Test ;
51
46
@@ -97,271 +92,9 @@ public virtual void CheckCatalogDictionaryWithoutEmbeddedFiles() {
97
92
public virtual void CheckValidCatalog ( ) {
98
93
pdfA1Checker . CheckCatalogValidEntries ( new PdfDictionary ( ) ) ;
99
94
}
100
-
101
95
// checkCatalogValidEntries doesn't change the state of any object
102
96
// and doesn't return any value. The only result is exception which
103
97
// was or wasn't thrown. Successful scenario is tested here therefore
104
98
// no assertion is provided
105
- [ NUnit . Framework . Test ]
106
- public virtual void IndependentLongStringTest ( ) {
107
- NUnit . Framework . Assert . That ( ( ) => {
108
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
109
- int testLength = maxAllowedLength + 1 ;
110
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
111
- PdfString longString = new PdfString ( PdfACheckerTestUtils . GetLongString ( testLength ) ) ;
112
- // An exception should be thrown as provided String is longer then
113
- // it is allowed per specification
114
- pdfA1Checker . CheckPdfObject ( longString ) ;
115
- }
116
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
117
- ;
118
- }
119
-
120
- [ NUnit . Framework . Test ]
121
- public virtual void IndependentNormalStringTest ( ) {
122
- int testLength = pdfA1Checker . GetMaxStringLength ( ) ;
123
- NUnit . Framework . Assert . AreEqual ( testLength , 65535 ) ;
124
- PdfString longString = new PdfString ( PdfACheckerTestUtils . GetLongString ( testLength ) ) ;
125
- // An exception should not be thrown as provided String matches
126
- // the limitations provided in specification
127
- pdfA1Checker . CheckPdfObject ( longString ) ;
128
- }
129
-
130
- [ NUnit . Framework . Test ]
131
- public virtual void LongStringInDictionaryTest ( ) {
132
- NUnit . Framework . Assert . That ( ( ) => {
133
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
134
- int testLength = maxAllowedLength + 1 ;
135
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
136
- PdfDictionary dict = new PdfDictionary ( ) ;
137
- dict . Put ( new PdfName ( "Key1" ) , new PdfString ( "value1" ) ) ;
138
- dict . Put ( new PdfName ( "Key2" ) , new PdfString ( "value2" ) ) ;
139
- dict . Put ( new PdfName ( "Key3" ) , new PdfString ( PdfACheckerTestUtils . GetLongString ( testLength ) ) ) ;
140
- // An exception should be thrown as value for 'key3' is longer then
141
- // it is allowed per specification
142
- pdfA1Checker . CheckPdfObject ( dict ) ;
143
- }
144
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
145
- ;
146
- }
147
-
148
- [ NUnit . Framework . Test ]
149
- public virtual void NormalStringInDictionaryTest ( ) {
150
- int testLength = pdfA1Checker . GetMaxStringLength ( ) ;
151
- PdfDictionary dict = new PdfDictionary ( ) ;
152
- dict . Put ( new PdfName ( "Key1" ) , new PdfString ( "value1" ) ) ;
153
- dict . Put ( new PdfName ( "Key2" ) , new PdfString ( "value2" ) ) ;
154
- dict . Put ( new PdfName ( "Key3" ) , new PdfString ( PdfACheckerTestUtils . GetLongString ( testLength ) ) ) ;
155
- // An exception should not be thrown as all values match the
156
- // limitations provided in specification
157
- pdfA1Checker . CheckPdfObject ( dict ) ;
158
- }
159
-
160
- [ NUnit . Framework . Test ]
161
- public virtual void LongStringInArrayTest ( ) {
162
- NUnit . Framework . Assert . That ( ( ) => {
163
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
164
- int testLength = maxAllowedLength + 1 ;
165
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
166
- PdfArray array = new PdfArray ( ) ;
167
- array . Add ( new PdfString ( "value1" ) ) ;
168
- array . Add ( new PdfString ( "value2" ) ) ;
169
- array . Add ( new PdfString ( PdfACheckerTestUtils . GetLongString ( testLength ) ) ) ;
170
- // An exception should be thrown as 3rd element is longer then
171
- // it is allowed per specification
172
- pdfA1Checker . CheckPdfObject ( array ) ;
173
- }
174
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
175
- ;
176
- }
177
-
178
- [ NUnit . Framework . Test ]
179
- public virtual void NormalStringInArrayTest ( ) {
180
- int testLength = pdfA1Checker . GetMaxStringLength ( ) ;
181
- NUnit . Framework . Assert . AreEqual ( testLength , 65535 ) ;
182
- PdfArray array = new PdfArray ( ) ;
183
- array . Add ( new PdfString ( "value1" ) ) ;
184
- array . Add ( new PdfString ( "value2" ) ) ;
185
- array . Add ( new PdfString ( PdfACheckerTestUtils . GetLongString ( testLength ) ) ) ;
186
- // An exception should not be thrown as all elements match the
187
- // limitations provided in specification
188
- pdfA1Checker . CheckPdfObject ( array ) ;
189
- }
190
-
191
- [ NUnit . Framework . Test ]
192
- public virtual void LongStringInContentStreamTest ( ) {
193
- NUnit . Framework . Assert . That ( ( ) => {
194
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
195
- int testLength = maxAllowedLength + 1 ;
196
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
197
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongString ( testLength ) ;
198
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
199
- PdfStream stream = new PdfStream ( newContent ) ;
200
- // An exception should be thrown as content stream has a string which
201
- // is longer then it is allowed per specification
202
- pdfA1Checker . CheckContentStream ( stream ) ;
203
- }
204
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
205
- ;
206
- }
207
-
208
- [ NUnit . Framework . Test ]
209
- public virtual void ContentStreamIsNotCheckedForNotModifiedObjectTest ( ) {
210
- pdfA1Checker . SetFullCheckMode ( false ) ;
211
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
212
- int testLength = maxAllowedLength + 1 ;
213
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
214
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongString ( testLength ) ;
215
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
216
- PdfStream stream = new PdfStream ( newContent ) ;
217
- // An exception should not be thrown as content stream considered as not modified
218
- // and won't be tested
219
- pdfA1Checker . CheckContentStream ( stream ) ;
220
- }
221
-
222
- [ NUnit . Framework . Test ]
223
- public virtual void NormalStringInContentStreamTest ( ) {
224
- int testLength = pdfA1Checker . GetMaxStringLength ( ) ;
225
- NUnit . Framework . Assert . AreEqual ( testLength , 65535 ) ;
226
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongString ( testLength ) ;
227
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
228
- PdfStream stream = new PdfStream ( newContent ) ;
229
- // An exception should be thrown as all strings inside content stream
230
- // are not longer then it is allowed per specification
231
- pdfA1Checker . CheckContentStream ( stream ) ;
232
- }
233
-
234
- [ NUnit . Framework . Test ]
235
- public virtual void LongStringInArrayInContentStreamTest ( ) {
236
- NUnit . Framework . Assert . That ( ( ) => {
237
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
238
- int testLength = maxAllowedLength + 1 ;
239
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
240
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongStringInArray ( testLength ) ;
241
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
242
- PdfStream stream = new PdfStream ( newContent ) ;
243
- // An exception should be thrown as content stream has a string which
244
- // is longer then it is allowed per specification
245
- pdfA1Checker . CheckContentStream ( stream ) ;
246
- }
247
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
248
- ;
249
- }
250
-
251
- [ NUnit . Framework . Test ]
252
- public virtual void LongStringInDictionaryInContentStreamTest ( ) {
253
- NUnit . Framework . Assert . That ( ( ) => {
254
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
255
- int testLength = maxAllowedLength + 1 ;
256
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
257
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongStringInDictionary ( testLength ) ;
258
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
259
- PdfStream stream = new PdfStream ( newContent ) ;
260
- // An exception should be thrown as content stream has a string which
261
- // is longer then it is allowed per specification
262
- pdfA1Checker . CheckContentStream ( stream ) ;
263
- }
264
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
265
- ;
266
- }
267
-
268
- [ NUnit . Framework . Test ]
269
- public virtual void LongStringInComplexStructureTest ( ) {
270
- NUnit . Framework . Assert . That ( ( ) => {
271
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
272
- int testLength = maxAllowedLength + 1 ;
273
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
274
- PdfDictionary dict1 = new PdfDictionary ( ) ;
275
- dict1 . Put ( new PdfName ( "Key1" ) , new PdfString ( "value1" ) ) ;
276
- dict1 . Put ( new PdfName ( "Key2" ) , new PdfString ( "value2" ) ) ;
277
- dict1 . Put ( new PdfName ( "Key3" ) , new PdfString ( PdfACheckerTestUtils . GetLongString ( testLength ) ) ) ;
278
- PdfArray array = new PdfArray ( ) ;
279
- array . Add ( new PdfString ( "value3" ) ) ;
280
- array . Add ( new PdfString ( "value4" ) ) ;
281
- array . Add ( dict1 ) ;
282
- PdfDictionary dict = new PdfDictionary ( ) ;
283
- dict . Put ( new PdfName ( "Key4" ) , new PdfString ( "value5" ) ) ;
284
- dict . Put ( new PdfName ( "Key5" ) , new PdfString ( "value6" ) ) ;
285
- dict . Put ( new PdfName ( "Key6" ) , array ) ;
286
- // An exception should be thrown as there is a string element which
287
- // doesn't match the limitations provided in specification
288
- pdfA1Checker . CheckPdfObject ( array ) ;
289
- }
290
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
291
- ;
292
- }
293
-
294
- [ NUnit . Framework . Test ]
295
- public virtual void LongStringInPdfFormXObjectTest ( ) {
296
- NUnit . Framework . Assert . That ( ( ) => {
297
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
298
- int testLength = maxAllowedLength + 1 ;
299
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
300
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongString ( testLength ) ;
301
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
302
- PdfStream stream = new PdfStream ( newContent ) ;
303
- PdfXObject xobject = new PdfFormXObject ( stream ) ;
304
- // An exception should be thrown as form xobject content stream has a string which
305
- // is longer then it is allowed per specification
306
- pdfA1Checker . CheckFormXObject ( xobject . GetPdfObject ( ) ) ;
307
- }
308
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
309
- ;
310
- }
311
-
312
- [ NUnit . Framework . Test ]
313
- public virtual void LongStringInTilingPatternTest ( ) {
314
- NUnit . Framework . Assert . That ( ( ) => {
315
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
316
- int testLength = maxAllowedLength + 1 ;
317
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
318
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongString ( testLength ) ;
319
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
320
- PdfPattern pattern = new PdfPattern . Tiling ( 200 , 200 ) ;
321
- ( ( PdfStream ) pattern . GetPdfObject ( ) ) . SetData ( newContent ) ;
322
- Color color = new PatternColor ( pattern ) ;
323
- // An exception should be thrown as tiling pattern's content stream has a string which
324
- // is longer then it is allowed per specification
325
- pdfA1Checker . CheckColor ( color , new PdfDictionary ( ) , true , null ) ;
326
- }
327
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
328
- ;
329
- }
330
-
331
- [ NUnit . Framework . Test ]
332
- public virtual void LongStringInShadingPatternTest ( ) {
333
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
334
- int testLength = maxAllowedLength + 1 ;
335
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
336
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongString ( testLength ) ;
337
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
338
- PdfStream stream = new PdfStream ( newContent ) ;
339
- PdfPattern pattern = new PdfPattern . Shading ( stream ) ;
340
- // An exception should not be thrown as shading pattern doesn't have
341
- // content stream to validate
342
- pdfA1Checker . CheckPdfObject ( pattern . GetPdfObject ( ) ) ;
343
- }
344
-
345
- [ NUnit . Framework . Test ]
346
- public virtual void LongStringInType3FontTest ( ) {
347
- NUnit . Framework . Assert . That ( ( ) => {
348
- int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
349
- int testLength = maxAllowedLength + 1 ;
350
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
351
- String newContentString = PdfACheckerTestUtils . GetStreamWithLongString ( testLength ) ;
352
- byte [ ] newContent = newContentString . GetBytes ( System . Text . Encoding . UTF8 ) ;
353
- PdfFont font = PdfFontFactory . CreateType3Font ( null , true ) ;
354
- PdfDictionary charProcs = new PdfDictionary ( ) ;
355
- charProcs . Put ( PdfName . A , new PdfStream ( newContent ) ) ;
356
- PdfDictionary dictionary = font . GetPdfObject ( ) ;
357
- dictionary . Put ( PdfName . Subtype , PdfName . Type3 ) ;
358
- dictionary . Put ( PdfName . CharProcs , charProcs ) ;
359
- // An exception should be thrown as content stream of type3 font has a string which
360
- // is longer then it is allowed per specification
361
- pdfA1Checker . CheckFont ( font ) ;
362
- }
363
- , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . PDF_STRING_IS_TOO_LONG ) )
364
- ;
365
- }
366
99
}
367
100
}
0 commit comments