Skip to content

Commit b41dec2

Browse files
Dmitry RadchukiText-CI
authored andcommitted
Fix PdfName limit and tag structure version for pdf/a-4
DEVSIX-7803 Autoported commit. Original commit hash: [3f3c7f357]
1 parent c4f4bb0 commit b41dec2

File tree

6 files changed

+44
-1
lines changed

6 files changed

+44
-1
lines changed

itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4CatalogCheckTest.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ You should have received a copy of the GNU Affero General Public License
2323
using System;
2424
using System.IO;
2525
using iText.Commons.Utils;
26+
using iText.Kernel.Font;
2627
using iText.Kernel.Geom;
2728
using iText.Kernel.Pdf;
2829
using iText.Kernel.Pdf.Canvas;
2930
using iText.Kernel.Pdf.Xobject;
3031
using iText.Kernel.Utils;
32+
using iText.Layout;
33+
using iText.Layout.Element;
3134
using iText.Pdfa.Exceptions;
3235
using iText.Test;
3336
using iText.Test.Pdfa;
@@ -60,6 +63,30 @@ public virtual void CreateSimpleDocTest() {
6063
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(outPdf));
6164
}
6265

66+
// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
67+
[NUnit.Framework.Test]
68+
public virtual void CreateSimpleTaggedDocTest() {
69+
String outPdf = destinationFolder + "pdfA4_tagged.pdf";
70+
String cmpPdf = sourceFolder + "cmp/PdfA4CatalogCheckTest/cmp_pdfA4_tagged.pdf";
71+
PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().SetPdfVersion(PdfVersion.PDF_2_0));
72+
Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
73+
PdfADocument pdfDoc = (PdfADocument)new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent
74+
("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", @is)).SetTagged();
75+
PdfFont font = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", PdfFontFactory.EmbeddingStrategy
76+
.FORCE_EMBEDDED);
77+
Document document = new Document(pdfDoc);
78+
document.SetFont(font);
79+
List list = new List();
80+
list.Add("123");
81+
document.Add(list);
82+
NUnit.Framework.Assert.AreEqual(PdfVersion.PDF_2_0, pdfDoc.GetTagStructureContext().GetTagStructureTargetVersion
83+
());
84+
document.Close();
85+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff"
86+
));
87+
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(outPdf));
88+
}
89+
6390
// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
6491
[NUnit.Framework.Test]
6592
public virtual void InvalidCatalogVersionCheckTest() {

itext.tests/itext.pdfa.tests/itext/pdfa/checker/PdfA4ImplementationLimitsTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ public virtual void DeviceNColorspaceWithMoreThan32Components() {
7575
pdfA4Checker.CheckColorSpace(BuildDeviceNColorspace(40), null, currentColorSpaces, true, false);
7676
}
7777

78+
[NUnit.Framework.Test]
79+
public virtual void LongPdfNameTest() {
80+
//exception shall not be thrown as pdf/a-4 supports greater than 127 characters pdf names
81+
pdfA4Checker.CheckPdfObject(PdfACheckerTestUtils.GetLongName(200));
82+
}
83+
7884
private PdfColorSpace BuildDeviceNColorspace(int numberOfComponents) {
7985
IList<String> tmpArray = new List<String>(numberOfComponents);
8086
float[] transformArray = new float[numberOfComponents * 2];
Binary file not shown.

itext/itext.pdfa/itext/pdfa/PdfADocument.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ private static PdfVersion GetPdfVersionForPdfA(PdfAConformanceLevel conformanceL
449449
break;
450450
}
451451

452+
case "4": {
453+
version = PdfVersion.PDF_2_0;
454+
break;
455+
}
456+
452457
default: {
453458
version = PdfVersion.PDF_1_4;
454459
break;

itext/itext.pdfa/itext/pdfa/checker/PdfA4Checker.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ protected internal override void CheckBlendMode(PdfName blendMode) {
422422
}
423423
}
424424

425+
/// <summary><inheritDoc/></summary>
426+
protected internal override int GetMaxNameLength() {
427+
return int.MaxValue;
428+
}
429+
425430
private static bool IsValidXmpConformance(String value) {
426431
if (value == null) {
427432
return false;

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
48292687dfcfa44a98eaf24005011750c7019a14
1+
3f3c7f35792059b0fddca8e224091ed039d28a8c

0 commit comments

Comments
 (0)