Skip to content

Commit 6177a07

Browse files
committed
Merge branch '7.1' into develop
# Conflicts: # layout/src/main/java/com/itextpdf/layout/minmaxwidth/MinMaxWidth.java # layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java # pdfa/src/main/java/com/itextpdf/pdfa/PdfAConformanceException.java # pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA2Checker.java # pdfa/src/test/java/com/itextpdf/pdfa/PdfA2GraphicsCheckTest.java Autoported commit. Original commit hash: [138eee3a3]
2 parents c22a957 + a44281b commit 6177a07

File tree

2,230 files changed

+18857
-244068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,230 files changed

+18857
-244068
lines changed

iTextCore.netstandard.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26430.14
4+
VisualStudioVersion = 15.0.26430.15
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "itext.io.netstandard", "itext\itext.io\itext.io.netstandard.csproj", "{4C4C74D4-00E2-43A4-9D7A-54352096DE32}"
77
EndProject

itext.tests/itext.barcodes.tests/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
[assembly: Guid("d015a3aa-613c-45d9-b908-7d47c4b613af")]
1616

17-
[assembly: AssemblyVersion("7.0.6.0")]
18-
[assembly: AssemblyFileVersion("7.0.6.0")]
19-
[assembly: AssemblyInformationalVersion("7.0.6-SNAPSHOT")]
17+
[assembly: AssemblyVersion("7.1.0.0")]
18+
[assembly: AssemblyFileVersion("7.1.0.0")]
19+
[assembly: AssemblyInformationalVersion("7.1.0-SNAPSHOT")]
2020

2121
#if !NETSTANDARD1_6
2222
[assembly: NUnit.Framework.Timeout(300000)]

itext.tests/itext.forms.tests/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
[assembly: Guid("6fe2f714-6b3e-4b20-8c70-28bfce084ed2")]
1616

17-
[assembly: AssemblyVersion("7.0.6.0")]
18-
[assembly: AssemblyFileVersion("7.0.6.0")]
19-
[assembly: AssemblyInformationalVersion("7.0.6-SNAPSHOT")]
17+
[assembly: AssemblyVersion("7.1.0.0")]
18+
[assembly: AssemblyFileVersion("7.1.0.0")]
19+
[assembly: AssemblyInformationalVersion("7.1.0-SNAPSHOT")]
2020

2121
#if !NETSTANDARD1_6
2222
[assembly: NUnit.Framework.Timeout(300000)]

itext.tests/itext.forms.tests/itext/forms/FormFieldsTaggingTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ source product.
4444
using iText.Forms.Fields;
4545
using iText.Kernel.Geom;
4646
using iText.Kernel.Pdf;
47+
using iText.Kernel.Pdf.Tagging;
4748
using iText.Kernel.Pdf.Tagutils;
4849
using iText.Kernel.Utils;
4950
using iText.Test;
@@ -189,7 +190,7 @@ public virtual void FormFieldTaggingTest07() {
189190
PdfButtonFormField pushButton = PdfFormField.CreatePushButton(pdfDoc, new Rectangle(36, 650, 40, 20), "push"
190191
, "Capcha");
191192
TagTreePointer tagPointer = pdfDoc.GetTagStructureContext().GetAutoTaggingPointer();
192-
tagPointer.MoveToKid(PdfName.Div);
193+
tagPointer.MoveToKid(StandardRoles.DIV);
193194
acroForm.AddField(pushButton);
194195
pdfDoc.Close();
195196
CompareOutput(outFileName, cmpFileName);

itext.tests/itext.forms.tests/itext/forms/PdfEncryptionTest.cs

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,36 @@ source product.
4141
4242
*/
4343
using System;
44+
using iText.Forms.Fields;
45+
using iText.Kernel.Geom;
4446
using iText.Kernel.Pdf;
47+
using iText.Kernel.Utils;
48+
using iText.Test;
4549

4650
namespace iText.Forms {
47-
public class PdfEncryptionTest {
51+
public class PdfEncryptionTest : ExtendedITextTest {
4852
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
4953
.CurrentContext.TestDirectory) + "/resources/itext/forms/PdfEncryptionTest/";
5054

55+
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
56+
+ "/test/itext/forms/PdfEncryptionTest/";
57+
58+
/// <summary>User password.</summary>
59+
public static byte[] USER = "Hello".GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1);
60+
61+
/// <summary>Owner password.</summary>
62+
public static byte[] OWNER = "World".GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1);
63+
64+
[NUnit.Framework.OneTimeSetUp]
65+
public static void BeforeClass() {
66+
ITextTest.CreateOrClearDestinationFolder(destinationFolder);
67+
}
68+
69+
internal const String customInfoEntryKey = "Custom";
70+
71+
internal const String customInfoEntryValue = "String";
72+
73+
// Custom entry in Info dictionary is used because standard entried are gone into metadata in PDF 2.0
5174
/// <exception cref="System.IO.IOException"/>
5275
[NUnit.Framework.Test]
5376
public virtual void EncryptedDocumentWithFormFields() {
@@ -58,5 +81,70 @@ public virtual void EncryptedDocumentWithFormFields() {
5881
acroForm.GetField("personal.name").GetPdfObject();
5982
pdfDocument.Close();
6083
}
84+
85+
/// <exception cref="System.Exception"/>
86+
/// <exception cref="System.IO.IOException"/>
87+
/// <exception cref="iText.Kernel.XMP.XMPException"/>
88+
[NUnit.Framework.Test]
89+
public virtual void EncryptAes256Pdf2PermissionsTest01() {
90+
String filename = "encryptAes256Pdf2PermissionsTest01.pdf";
91+
int permissions = EncryptionConstants.ALLOW_FILL_IN | EncryptionConstants.ALLOW_SCREENREADERS | EncryptionConstants
92+
.ALLOW_DEGRADED_PRINTING;
93+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(destinationFolder + filename, new WriterProperties().SetPdfVersion
94+
(PdfVersion.PDF_2_0).SetStandardEncryption(USER, OWNER, permissions, EncryptionConstants.ENCRYPTION_AES_256
95+
)));
96+
pdfDoc.GetDocumentInfo().SetMoreInfo(customInfoEntryKey, customInfoEntryValue);
97+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
98+
PdfTextFormField textField1 = PdfFormField.CreateText(pdfDoc, new Rectangle(100, 600, 200, 30), "Name", "Enter your name"
99+
);
100+
form.AddField(textField1);
101+
PdfTextFormField textField2 = PdfFormField.CreateText(pdfDoc, new Rectangle(100, 550, 200, 30), "Surname",
102+
"Enter your surname");
103+
form.AddField(textField2);
104+
PdfButtonFormField group = PdfFormField.CreateRadioGroup(pdfDoc, "Sex", "Male");
105+
PdfFormField.CreateRadioButton(pdfDoc, new Rectangle(100, 530, 10, 10), group, "Male");
106+
PdfFormField.CreateRadioButton(pdfDoc, new Rectangle(120, 530, 10, 10), group, "Female");
107+
form.AddField(group);
108+
pdfDoc.Close();
109+
CompareTool compareTool = new CompareTool();
110+
String errorMessage = compareTool.CompareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename
111+
, destinationFolder, "diff_", USER, USER);
112+
if (errorMessage != null) {
113+
NUnit.Framework.Assert.Fail(errorMessage);
114+
}
115+
}
116+
117+
/// <exception cref="System.Exception"/>
118+
/// <exception cref="System.IO.IOException"/>
119+
/// <exception cref="iText.Kernel.XMP.XMPException"/>
120+
[NUnit.Framework.Test]
121+
public virtual void EncryptAes256Pdf2PermissionsTest02() {
122+
String filename = "encryptAes256Pdf2PermissionsTest02.pdf";
123+
// This test differs from the previous one (encryptAes256Pdf2PermissionsTest01) only in permissions.
124+
// Here we do not allow to fill the form in.
125+
int permissions = EncryptionConstants.ALLOW_SCREENREADERS | EncryptionConstants.ALLOW_DEGRADED_PRINTING;
126+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(destinationFolder + filename, new WriterProperties().SetPdfVersion
127+
(PdfVersion.PDF_2_0).SetStandardEncryption(USER, OWNER, permissions, EncryptionConstants.ENCRYPTION_AES_256
128+
)));
129+
pdfDoc.GetDocumentInfo().SetMoreInfo(customInfoEntryKey, customInfoEntryValue);
130+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
131+
PdfTextFormField textField1 = PdfFormField.CreateText(pdfDoc, new Rectangle(100, 600, 200, 30), "Name", "Enter your name"
132+
);
133+
form.AddField(textField1);
134+
PdfTextFormField textField2 = PdfFormField.CreateText(pdfDoc, new Rectangle(100, 550, 200, 30), "Surname",
135+
"Enter your surname");
136+
form.AddField(textField2);
137+
PdfButtonFormField group = PdfFormField.CreateRadioGroup(pdfDoc, "Sex", "Male");
138+
PdfFormField.CreateRadioButton(pdfDoc, new Rectangle(100, 530, 10, 10), group, "Male");
139+
PdfFormField.CreateRadioButton(pdfDoc, new Rectangle(120, 530, 10, 10), group, "Female");
140+
form.AddField(group);
141+
pdfDoc.Close();
142+
CompareTool compareTool = new CompareTool();
143+
String errorMessage = compareTool.CompareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename
144+
, destinationFolder, "diff_", USER, USER);
145+
if (errorMessage != null) {
146+
NUnit.Framework.Assert.Fail(errorMessage);
147+
}
148+
}
61149
}
62150
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using iText.Forms.Fields;
4+
using iText.IO.Font;
5+
using iText.Kernel.Font;
6+
using iText.Kernel.Geom;
7+
using iText.Kernel.Pdf;
8+
using iText.Kernel.Utils;
9+
using iText.Test;
10+
11+
namespace iText.Forms {
12+
public class Utf8FormsTest {
13+
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
14+
.CurrentContext.TestDirectory) + "/resources/itext/forms/Utf8FormsTest/";
15+
16+
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
17+
+ "/test/itext/forms/Utf8FormsTest/";
18+
19+
public static readonly String FONT = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
20+
.CurrentContext.TestDirectory) + "/resources/itext/forms/Utf8FormsTest/NotoSansCJKsc-Regular.otf";
21+
22+
[NUnit.Framework.SetUp]
23+
public virtual void Before() {
24+
ITextTest.CreateDestinationFolder(destinationFolder);
25+
}
26+
27+
/// <exception cref="System.IO.IOException"/>
28+
/// <exception cref="System.Exception"/>
29+
[NUnit.Framework.Test]
30+
public virtual void ReadUtf8FieldName() {
31+
String filename = sourceFolder + "utf-8-field-name.pdf";
32+
PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename));
33+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
34+
IDictionary<String, PdfFormField> fields = form.GetFormFields();
35+
pdfDoc.Close();
36+
foreach (String fldName in fields.Keys) {
37+
// لا
38+
NUnit.Framework.Assert.AreEqual("\u0644\u0627", fldName);
39+
}
40+
pdfDoc.Close();
41+
}
42+
43+
/// <exception cref="System.IO.IOException"/>
44+
/// <exception cref="System.Exception"/>
45+
[NUnit.Framework.Test]
46+
public virtual void ReadUtf8TextAnnot() {
47+
String filename = sourceFolder + "utf-8-text-annot.pdf";
48+
PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename));
49+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
50+
IDictionary<String, PdfFormField> fields = form.GetFormFields();
51+
pdfDoc.Close();
52+
foreach (String fldName in fields.Keys) {
53+
// 福昕 福昕UTF8
54+
NUnit.Framework.Assert.AreEqual("\u798F\u6615 \u798F\u6615UTF8", fields.Get(fldName).GetValueAsString());
55+
}
56+
}
57+
58+
/// <exception cref="System.IO.IOException"/>
59+
/// <exception cref="System.Exception"/>
60+
[NUnit.Framework.Test]
61+
public virtual void WriteUtf8FieldNameAndValue() {
62+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(destinationFolder + "writeUtf8FieldNameAndValue.pdf"));
63+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
64+
PdfTextFormField field = PdfTextFormField.CreateText(pdfDoc, new Rectangle(99, 753, 425, 15), "", "");
65+
field.SetFont(PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H));
66+
// لا
67+
field.Put(PdfName.T, new PdfString("\u0644\u0627", PdfEncodings.UTF8));
68+
// 福昕 福昕UTF8
69+
field.Put(PdfName.V, new PdfString("\u798F\u6615 \u798F\u6615UTF8", PdfEncodings.UTF8));
70+
field.RegenerateField();
71+
form.AddField(field);
72+
pdfDoc.Close();
73+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + "writeUtf8FieldNameAndValue.pdf"
74+
, sourceFolder + "cmp_writeUtf8FieldNameAndValue.pdf", destinationFolder, "diffFieldNameAndValue_"));
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)