Skip to content

Commit 0a0530d

Browse files
Kate IvanovaiText-CI
authored andcommitted
Add new Pdfa2Checker and Pdfa3Checker tests
1. Create PdfA3CatalogCheckTest class 2. Add new tests: PdfA2CatalogCheckTest#checkAbsenceOfOptionalConfigEntry; PdfA2CatalogCheckTest#checkAbsenceOfOptionalOrderEntry; PdfA3CatalogCheckTest#checkAbsenceOfConfigEntry; PdfA3CatalogCheckTest#checkAbsenceOfOrderEntry. DEVSIX-3206 Autoported commit. Original commit hash: [45100439d]
1 parent 0ddb2d2 commit 0a0530d

File tree

3 files changed

+165
-1
lines changed

3 files changed

+165
-1
lines changed

itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2CatalogCheckTest.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,61 @@ public virtual void CatalogCheck10() {
342342
;
343343
}
344344

345+
[NUnit.Framework.Test]
346+
public virtual void CheckAbsenceOfOptionalConfigEntry() {
347+
NUnit.Framework.Assert.That(() => {
348+
//TODO Remove expected exception when DEVSIX-3206 will be fixed
349+
PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
350+
Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
351+
PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
352+
, "http://www.color.org", "sRGB IEC61966-2.1", @is));
353+
doc.AddNewPage();
354+
PdfDictionary ocProperties = new PdfDictionary();
355+
PdfDictionary d = new PdfDictionary();
356+
d.Put(PdfName.Name, new PdfString("CustomName"));
357+
PdfDictionary orderItem = new PdfDictionary();
358+
orderItem.Put(PdfName.Name, new PdfString("CustomName2"));
359+
PdfArray ocgs = new PdfArray();
360+
ocgs.Add(orderItem);
361+
ocProperties.Put(PdfName.OCGs, ocgs);
362+
ocProperties.Put(PdfName.D, d);
363+
doc.GetCatalog().Put(PdfName.OCProperties, ocProperties);
364+
doc.Close();
365+
}
366+
, NUnit.Framework.Throws.InstanceOf<PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS))
367+
;
368+
}
369+
370+
[NUnit.Framework.Test]
371+
public virtual void CheckAbsenceOfOptionalOrderEntry() {
372+
NUnit.Framework.Assert.That(() => {
373+
//TODO Remove expected exception when DEVSIX-3206 will be fixed
374+
PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
375+
Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
376+
PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
377+
, "http://www.color.org", "sRGB IEC61966-2.1", @is));
378+
doc.AddNewPage();
379+
PdfDictionary ocProperties = new PdfDictionary();
380+
PdfDictionary d = new PdfDictionary();
381+
d.Put(PdfName.Name, new PdfString("CustomName"));
382+
PdfDictionary orderItem = new PdfDictionary();
383+
orderItem.Put(PdfName.Name, new PdfString("CustomName2"));
384+
PdfArray ocgs = new PdfArray();
385+
ocgs.Add(orderItem);
386+
PdfArray configs = new PdfArray();
387+
PdfDictionary config = new PdfDictionary();
388+
config.Put(PdfName.Name, new PdfString("CustomName1"));
389+
configs.Add(config);
390+
ocProperties.Put(PdfName.OCGs, ocgs);
391+
ocProperties.Put(PdfName.D, d);
392+
ocProperties.Put(PdfName.Configs, configs);
393+
doc.GetCatalog().Put(PdfName.OCProperties, ocProperties);
394+
doc.Close();
395+
}
396+
, NUnit.Framework.Throws.InstanceOf<PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS))
397+
;
398+
}
399+
345400
private void CompareResult(String outPdf, String cmpPdf) {
346401
String result = new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff_");
347402
if (result != null) {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2020 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License version 3
8+
as published by the Free Software Foundation with the addition of the
9+
following permission added to Section 15 as permitted in Section 7(a):
10+
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
11+
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
12+
OF THIRD PARTY RIGHTS
13+
14+
This program is distributed in the hope that it will be useful, but
15+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
or FITNESS FOR A PARTICULAR PURPOSE.
17+
See the GNU Affero General Public License for more details.
18+
You should have received a copy of the GNU Affero General Public License
19+
along with this program; if not, see http://www.gnu.org/licenses or write to
20+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21+
Boston, MA, 02110-1301 USA, or download the license from the following URL:
22+
http://itextpdf.com/terms-of-use/
23+
24+
The interactive user interfaces in modified source and object code versions
25+
of this program must display Appropriate Legal Notices, as required under
26+
Section 5 of the GNU Affero General Public License.
27+
28+
In accordance with Section 7(b) of the GNU Affero General Public License,
29+
a covered work must retain the producer line in every PDF that is created
30+
or manipulated using iText.
31+
32+
You can be released from the requirements of the license by purchasing
33+
a commercial license. Buying such a license is mandatory as soon as you
34+
develop commercial activities involving the iText software without
35+
disclosing the source code of your own applications.
36+
These activities include: offering paid services to customers as an ASP,
37+
serving PDFs on the fly in a web application, shipping iText with a closed
38+
source product.
39+
40+
For more information, please contact iText Software Corp. at this
41+
42+
*/
43+
using System;
44+
using System.IO;
45+
using iText.IO.Source;
46+
using iText.Kernel.Pdf;
47+
using iText.Test;
48+
49+
namespace iText.Pdfa {
50+
public class PdfA3CatalogCheckTest : ExtendedITextTest {
51+
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
52+
.CurrentContext.TestDirectory) + "/resources/itext/pdfa/";
53+
54+
[NUnit.Framework.Test]
55+
public virtual void CheckAbsenceOfConfigEntry() {
56+
NUnit.Framework.Assert.That(() => {
57+
//TODO Remove expected exception when DEVSIX-3206 will be fixed
58+
PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
59+
Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
60+
PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", ""
61+
, "http://www.color.org", "sRGB IEC61966-2.1", @is));
62+
doc.AddNewPage();
63+
PdfDictionary ocProperties = new PdfDictionary();
64+
PdfDictionary d = new PdfDictionary();
65+
d.Put(PdfName.Name, new PdfString("CustomName"));
66+
PdfDictionary orderItem = new PdfDictionary();
67+
orderItem.Put(PdfName.Name, new PdfString("CustomName2"));
68+
PdfArray ocgs = new PdfArray();
69+
ocgs.Add(orderItem);
70+
ocProperties.Put(PdfName.OCGs, ocgs);
71+
ocProperties.Put(PdfName.D, d);
72+
doc.GetCatalog().Put(PdfName.OCProperties, ocProperties);
73+
doc.Close();
74+
}
75+
, NUnit.Framework.Throws.InstanceOf<PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS))
76+
;
77+
}
78+
79+
[NUnit.Framework.Test]
80+
public virtual void CheckAbsenceOfOrderEntry() {
81+
NUnit.Framework.Assert.That(() => {
82+
//TODO Remove expected exception when DEVSIX-3206 will be fixed
83+
PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
84+
Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
85+
PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", ""
86+
, "http://www.color.org", "sRGB IEC61966-2.1", @is));
87+
doc.AddNewPage();
88+
PdfDictionary ocProperties = new PdfDictionary();
89+
PdfDictionary d = new PdfDictionary();
90+
d.Put(PdfName.Name, new PdfString("CustomName"));
91+
PdfDictionary orderItem = new PdfDictionary();
92+
orderItem.Put(PdfName.Name, new PdfString("CustomName2"));
93+
PdfArray ocgs = new PdfArray();
94+
ocgs.Add(orderItem);
95+
PdfArray configs = new PdfArray();
96+
PdfDictionary config = new PdfDictionary();
97+
config.Put(PdfName.Name, new PdfString("CustomName1"));
98+
configs.Add(config);
99+
ocProperties.Put(PdfName.OCGs, ocgs);
100+
ocProperties.Put(PdfName.D, d);
101+
ocProperties.Put(PdfName.Configs, configs);
102+
doc.GetCatalog().Put(PdfName.OCProperties, ocProperties);
103+
doc.Close();
104+
}
105+
, NUnit.Framework.Throws.InstanceOf<PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS))
106+
;
107+
}
108+
}
109+
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1d70930ef29dd06c4342d3db507fe7b846fb3661
1+
45100439dfb627839aaacaa874862cae01f84dda

0 commit comments

Comments
 (0)