Skip to content

Commit 93efbdb

Browse files
committed
Merge branch 'release/7.1.0'
2 parents c90df04 + b649455 commit 93efbdb

File tree

2,246 files changed

+21237
-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,246 files changed

+21237
-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.5.0")]
18-
[assembly: AssemblyFileVersion("7.0.5.0")]
19-
[assembly: AssemblyInformationalVersion("7.0.5")]
17+
[assembly: AssemblyVersion("7.1.0.0")]
18+
[assembly: AssemblyFileVersion("7.1.0.0")]
19+
[assembly: AssemblyInformationalVersion("7.1.0")]
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.5.0")]
18-
[assembly: AssemblyFileVersion("7.0.5.0")]
19-
[assembly: AssemblyInformationalVersion("7.0.5")]
17+
[assembly: AssemblyVersion("7.1.0.0")]
18+
[assembly: AssemblyFileVersion("7.1.0.0")]
19+
[assembly: AssemblyInformationalVersion("7.1.0")]
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
}

itext.tests/itext.forms.tests/itext/forms/PdfFormFieldTest.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,43 @@ public virtual void AcroFieldDictionaryNoFields() {
322322
NUnit.Framework.Assert.Fail(errorMessage);
323323
}
324324
}
325+
326+
/// <exception cref="System.IO.IOException"/>
327+
/// <exception cref="System.Exception"/>
328+
[NUnit.Framework.Test]
329+
public virtual void RegenerateAppearance() {
330+
String input = "regenerateAppearance.pdf";
331+
String output = "regenerateAppearance.pdf";
332+
PdfDocument document = new PdfDocument(new PdfReader(sourceFolder + input), new PdfWriter(destinationFolder
333+
+ output), new StampingProperties().UseAppendMode());
334+
PdfAcroForm acro = PdfAcroForm.GetAcroForm(document, false);
335+
int i = 1;
336+
foreach (KeyValuePair<String, PdfFormField> entry in acro.GetFormFields()) {
337+
if (entry.Key.Contains("field")) {
338+
PdfFormField field = entry.Value;
339+
field.SetValue("test" + i++, false);
340+
}
341+
}
342+
document.Close();
343+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + output, sourceFolder
344+
+ "cmp_" + output, destinationFolder, "diff"));
345+
}
346+
347+
/// <exception cref="System.IO.IOException"/>
348+
/// <exception cref="System.Exception"/>
349+
[NUnit.Framework.Test]
350+
public virtual void RegenerateAppearance2() {
351+
String input = "regenerateAppearance2.pdf";
352+
String output = "regenerateAppearance2.pdf";
353+
PdfDocument document = new PdfDocument(new PdfReader(sourceFolder + input), new PdfWriter(destinationFolder
354+
+ output), new StampingProperties().UseAppendMode());
355+
PdfAcroForm acro = PdfAcroForm.GetAcroForm(document, false);
356+
acro.SetNeedAppearances(true);
357+
PdfFormField field = acro.GetField("number");
358+
field.SetValue("20150044DR");
359+
document.Close();
360+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + output, sourceFolder
361+
+ "cmp_" + output, destinationFolder, "diff"));
362+
}
325363
}
326364
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2017 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.Collections.Generic;
45+
using iText.Forms.Fields;
46+
using iText.IO.Font;
47+
using iText.Kernel.Font;
48+
using iText.Kernel.Geom;
49+
using iText.Kernel.Pdf;
50+
using iText.Kernel.Utils;
51+
using iText.Test;
52+
53+
namespace iText.Forms {
54+
public class Utf8FormsTest {
55+
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
56+
.CurrentContext.TestDirectory) + "/resources/itext/forms/Utf8FormsTest/";
57+
58+
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
59+
+ "/test/itext/forms/Utf8FormsTest/";
60+
61+
public static readonly String FONT = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
62+
.CurrentContext.TestDirectory) + "/resources/itext/forms/Utf8FormsTest/NotoSansCJKsc-Regular.otf";
63+
64+
[NUnit.Framework.SetUp]
65+
public virtual void Before() {
66+
ITextTest.CreateDestinationFolder(destinationFolder);
67+
}
68+
69+
/// <exception cref="System.IO.IOException"/>
70+
/// <exception cref="System.Exception"/>
71+
[NUnit.Framework.Test]
72+
public virtual void ReadUtf8FieldName() {
73+
String filename = sourceFolder + "utf-8-field-name.pdf";
74+
PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename));
75+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
76+
IDictionary<String, PdfFormField> fields = form.GetFormFields();
77+
pdfDoc.Close();
78+
foreach (String fldName in fields.Keys) {
79+
// لا
80+
NUnit.Framework.Assert.AreEqual("\u0644\u0627", fldName);
81+
}
82+
pdfDoc.Close();
83+
}
84+
85+
/// <exception cref="System.IO.IOException"/>
86+
/// <exception cref="System.Exception"/>
87+
[NUnit.Framework.Test]
88+
public virtual void ReadUtf8TextAnnot() {
89+
String filename = sourceFolder + "utf-8-text-annot.pdf";
90+
PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename));
91+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
92+
IDictionary<String, PdfFormField> fields = form.GetFormFields();
93+
pdfDoc.Close();
94+
foreach (String fldName in fields.Keys) {
95+
// 福昕 福昕UTF8
96+
NUnit.Framework.Assert.AreEqual("\u798F\u6615 \u798F\u6615UTF8", fields.Get(fldName).GetValueAsString());
97+
}
98+
}
99+
100+
/// <exception cref="System.IO.IOException"/>
101+
/// <exception cref="System.Exception"/>
102+
[NUnit.Framework.Test]
103+
public virtual void WriteUtf8FieldNameAndValue() {
104+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(destinationFolder + "writeUtf8FieldNameAndValue.pdf"));
105+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
106+
PdfTextFormField field = PdfTextFormField.CreateText(pdfDoc, new Rectangle(99, 753, 425, 15), "", "");
107+
field.SetFont(PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H));
108+
// لا
109+
field.Put(PdfName.T, new PdfString("\u0644\u0627", PdfEncodings.UTF8));
110+
// 福昕 福昕UTF8
111+
field.Put(PdfName.V, new PdfString("\u798F\u6615 \u798F\u6615UTF8", PdfEncodings.UTF8));
112+
field.RegenerateField();
113+
form.AddField(field);
114+
pdfDoc.Close();
115+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + "writeUtf8FieldNameAndValue.pdf"
116+
, sourceFolder + "cmp_writeUtf8FieldNameAndValue.pdf", destinationFolder, "diffFieldNameAndValue_"));
117+
}
118+
}
119+
}

0 commit comments

Comments
 (0)