Skip to content

Commit 8e7cf1d

Browse files
committed
[RELEASE] iText 7 Core - 7.1.11
https://github.com/itext/itext7-dotnet/releases/tag/7.1.11 * release/7.1.11: Revert 'protected' FontSelectorStrategy#tempFonts field renaming [RELEASE] 7.1.11-SNAPSHOT -> 7.1.11 Update autoported files Add missing copyright headers Cover AreaBreakRenderer with unit tests Let PointTest extend ExtendedITextTest. Remove DefaultStylesTest#inheritedDefaultStyleTest Add missing copyright headers Update port-hash Improve layout's Style code coverage Change deprecated iconUrl icon to icon tag in nuspec files Move PdfPagesTest tests from samples internal Add PointTest Add tests on tiff image extraction Consider not set LINE_HEIGHT property to be exactly the same as LineHeight.NORMAL Add InheritedPageEntriesTest#setRotationToPageTest Unignore a test on Float.MIN_VALUE. Update autoported files Update port-hash Add missing copyright headers Take epsilon into account while deciding whether a cell of a fixed height sgould be split. Add html mode check for LineRenderer childs Add new tests for tiff images Add properties and default values for orphans and widows css support Add new Pdfa2Checker and Pdfa3Checker tests Add comment to MemoryLimitsAwareOutputStream#write() Deprecate one of Canvas constructors Add missing copyright headers Improve isVersionNumeric. Change the accessability of some Version methods from private to default. Cover Version with tests. Add tests for grayscale alpha png without embedded profile Move PdfColorSpace test from samples internal, add unit test Add MonospaceFontTest test Revert to typo_ascender scale coefficient usage for Type1Fonts for HTML mode Fix TextRenderer #resolveFirstPdfFont, refactor Property#FONT_SET usage documentation Implement HTML-like line-stacking algorithm in layout. Implement ascender/descender calculation according to CSS specification. Add new tests on orphans and widows Add missing copyright headers Add integration tests for orphans/widows Support orphans/widows processing Handle collapsing margins info in relayouting context Add new test for collapsing margins Deprecated redundant field in ParagraphRenderer Add missing copyrights headers Substitute RND tickets numbers to DEVSIX Add missing copyright headers Change the type of expected exception Extend Test classes from ExtendedITextTest to check log messages Move xfa form test to forms repository Add category to test classes Move test from samples internal repository Move hugeDocumentWithFullCompression test to manual tests repository Add PdfAIndirectResourcesTest class Process fillOpacity and strokeOpacity in GraphicsState Processor Explicitly add System.Net.Http v4.3.0 dependency to pdftest module, add UrlUtil#OpenStream test Move, add pattern color tests to kernel repository, add Logger to PdfCanvasProcessor, add LogMessageConstant class for kernel module Update autoported files Ignore all exceptions in EventDataHandler finalizer Improve documentation of PdfPKCS7#getTimeStampDate. Make UNDEFINED_TIMESTAMP_DATE public and move to a separate class Add PdfAStampingModeTest and signature field tests Update port-hash Add missing copyright headers Add ClipperException and ClipperExceptionConstant classes Add PdfCanvasParserTest#innerArraysInContentStreamTest Add PdfContentExtractionTest#contentExtractionInDocWithBigCoordinatesTest Add InlineImageExtractionTest#parseInlineImageTest Refactor URL links generation Add a test which demonstrate an NPE while processing cells with big rowspans Add missing copyright headers Fix mark to ligature positioning in GposLookupType5 Replace CorruptedTagStructureTest from samples-internal repo Add some tests to cover big rowspan splits Pdftest update, EventCounterHandler update Add missing copyright headers Make fringe attribute of square annotation optional Refactor CompareTool.compareXmls(String, String) method Add missing copyright headers Add ShapeTransformUtil class and add unit tests Add missing copyright headers Fix colorspace processing for png images Add PngTest class and new tests Add a test which demonstrates a NPE bein thrown while processing links Replace character with its unicode representation Refactor IsIgnoredClassOrPackage method Update port-hash Update port-hash Fix inserting whitespaces and newline charachers in RegexBasedLocationExtractionStrategy fix missing index and newlines in cleanup regexes Make log message more general, when FormField cannot be created and add nullFormFieldTest Fix null pointer in PdfAcroForm Refactor and improve some tests of TableRendererTest Update PdfMerger and PdfDocument JavaDoc Update port-hash after release [RELEASE] Update dependency versions Add tests for svg wrong font-size case Update documentation for page events Add missing copyright headers Replace tests from samples-internal repo and add new tests Add new tests on page entries Consider /TI when highlighting selected choice fields Add I key to every choice field for backward compatibility Support handling of I key of choice fields in accordance with spec Add missing copyright headers Add SmartModePdfObjectSerializerTest class Review PdfPagesTest commented tests; add test for parsing form xobjects with circular references Make EmptySet#remove behave the same way as in Java
2 parents 3aef486 + 1a6fcf2 commit 8e7cf1d

File tree

383 files changed

+8613
-929
lines changed

Some content is hidden

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

383 files changed

+8613
-929
lines changed

ITSC-avatar.png

2.7 KB
Loading

doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
3232
# title of most generated pages and in a few other places.
3333
# The default value is: My Project.
3434

35-
PROJECT_NAME = "iText 7 7.1.10 API"
35+
PROJECT_NAME = "iText 7 7.1.11 API"
3636

3737
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
3838
# could be handy for archiving the generated documentation or if some version

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.1.10.0")]
18-
[assembly: AssemblyFileVersion("7.1.10.0")]
19-
[assembly: AssemblyInformationalVersion("7.1.10")]
17+
[assembly: AssemblyVersion("7.1.11.0")]
18+
[assembly: AssemblyFileVersion("7.1.11.0")]
19+
[assembly: AssemblyInformationalVersion("7.1.11")]
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.1.10.0")]
18-
[assembly: AssemblyFileVersion("7.1.10.0")]
19-
[assembly: AssemblyInformationalVersion("7.1.10")]
17+
[assembly: AssemblyVersion("7.1.11.0")]
18+
[assembly: AssemblyFileVersion("7.1.11.0")]
19+
[assembly: AssemblyInformationalVersion("7.1.11")]
2020

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

itext.tests/itext.forms.tests/itext/forms/PdfChoiceFieldTest.cs

Lines changed: 166 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ You should have received a copy of the GNU Affero General Public License
2222
*/
2323
using System;
2424
using iText.Forms.Fields;
25+
using iText.IO.Font;
2526
using iText.Kernel.Colors;
2627
using iText.Kernel.Font;
2728
using iText.Kernel.Geom;
2829
using iText.Kernel.Pdf;
2930
using iText.Kernel.Utils;
3031
using iText.Test;
32+
using iText.Test.Attributes;
3133

3234
namespace iText.Forms {
33-
public class PdfChoiceFieldTest {
35+
public class PdfChoiceFieldTest : ExtendedITextTest {
3436
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
3537
+ "/test/itext/forms/PdfChoiceFieldTest/";
3638

@@ -39,7 +41,7 @@ public class PdfChoiceFieldTest {
3941

4042
[NUnit.Framework.OneTimeSetUp]
4143
public static void BeforeClass() {
42-
ITextTest.CreateOrClearDestinationFolder(destinationFolder);
44+
CreateOrClearDestinationFolder(destinationFolder);
4345
}
4446

4547
[NUnit.Framework.Test]
@@ -65,10 +67,171 @@ public virtual void ChoiceFieldsWithUnicodeTest() {
6567
[] { "\u89c4", "\u89c9" }, font, null).SetValue("\u89c9").SetBorderColor(ColorConstants.BLACK));
6668
pdfDoc.Close();
6769
CompareTool compareTool = new CompareTool();
68-
String errorMessage = compareTool.CompareByContent(outPdf, cmpPdf, destinationFolder, "diff_");
70+
String errorMessage = compareTool.CompareByContent(outPdf, cmpPdf, destinationFolder);
6971
if (errorMessage != null) {
7072
NUnit.Framework.Assert.Fail(errorMessage);
7173
}
7274
}
75+
76+
[NUnit.Framework.Test]
77+
public virtual void ChoiceFieldsSetValueTest() {
78+
String srcPdf = sourceFolder + "choiceFieldsWithUnnecessaryIEntries.pdf";
79+
String outPdf = destinationFolder + "choiceFieldsSetValueTest.pdf";
80+
String cmpPdf = sourceFolder + "cmp_choiceFieldsSetValueTest.pdf";
81+
PdfDocument pdfDocument = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
82+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDocument, false);
83+
PdfFormField firstField = form.GetField("First");
84+
PdfFormField secondField = form.GetField("Second");
85+
firstField.SetValue("First");
86+
secondField.SetValue("Second");
87+
PdfArray indicesFirst = ((PdfChoiceFormField)firstField).GetIndices();
88+
PdfArray indicesSecond = ((PdfChoiceFormField)secondField).GetIndices();
89+
PdfArray expectedIndicesFirst = new PdfArray(new int[] { 1 });
90+
PdfArray expectedIndicesSecond = new PdfArray(new int[] { 2 });
91+
CompareTool compareTool = new CompareTool();
92+
NUnit.Framework.Assert.IsTrue(compareTool.CompareArrays(indicesFirst, expectedIndicesFirst));
93+
NUnit.Framework.Assert.IsTrue(compareTool.CompareArrays(indicesSecond, expectedIndicesSecond));
94+
pdfDocument.Close();
95+
NUnit.Framework.Assert.IsNull(compareTool.CompareByContent(outPdf, cmpPdf, destinationFolder));
96+
}
97+
98+
[NUnit.Framework.Test]
99+
public virtual void ComboNoHighlightOfChosenFirstItemTest() {
100+
String srcPdf = sourceFolder + "comboNoHighlightOfChosenFirstItemTest.pdf";
101+
String outPdf = destinationFolder + "comboNoHighlightOfChosenFirstItemTest.pdf";
102+
String cmpPdf = sourceFolder + "cmp_comboNoHighlightOfChosenFirstItemTest.pdf";
103+
PdfDocument pdfDocument = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
104+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDocument, false);
105+
form.GetField("First").SetValue("Default");
106+
// flattening is only used for the sake of ease to see what appearance is generated by iText
107+
form.FlattenFields();
108+
pdfDocument.Close();
109+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
110+
}
111+
112+
[NUnit.Framework.Test]
113+
public virtual void NoWarningOnValueNotOfOptComboEditTest() {
114+
String srcPdf = sourceFolder + "noWarningOnValueNotOfOptComboEditTest.pdf";
115+
String outPdf = destinationFolder + "noWarningOnValueNotOfOptComboEditTest.pdf";
116+
String cmpPdf = sourceFolder + "cmp_noWarningOnValueNotOfOptComboEditTest.pdf";
117+
PdfDocument pdfDocument = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
118+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDocument, false);
119+
form.GetField("First").SetValue("Value not of /Opt array");
120+
pdfDocument.Close();
121+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
122+
}
123+
124+
[NUnit.Framework.Test]
125+
[LogMessage(iText.IO.LogMessageConstant.FIELD_VALUE_IS_NOT_CONTAINED_IN_OPT_ARRAY, Count = 2)]
126+
public virtual void MultiSelectByValueTest() {
127+
String outPdf = destinationFolder + "multiSelectByValueTest.pdf";
128+
String cmpPdf = sourceFolder + "cmp_multiSelectByValueTest.pdf";
129+
PdfDocument document = new PdfDocument(new PdfWriter(outPdf));
130+
document.AddNewPage();
131+
PdfAcroForm form = PdfAcroForm.GetAcroForm(document, true);
132+
PdfChoiceFormField choice = (PdfChoiceFormField)PdfFormField.CreateList(document, new Rectangle(336, 666,
133+
50, 80), "choice", "two", new String[] { "one", "two", "three", "four" }, null, null).SetBorderColor(ColorConstants
134+
.BLACK);
135+
choice.SetMultiSelect(true);
136+
choice.SetListSelected(new String[] { "one", "three", "eins", "drei" });
137+
NUnit.Framework.Assert.AreEqual(new int[] { 0, 2 }, choice.GetIndices().ToIntArray());
138+
PdfArray values = (PdfArray)choice.GetValue();
139+
String[] valuesAsStrings = new String[values.Size()];
140+
for (int i = 0; i < values.Size(); i++) {
141+
valuesAsStrings[i] = values.GetAsString(i).ToUnicodeString();
142+
}
143+
NUnit.Framework.Assert.AreEqual(new String[] { "one", "three", "eins", "drei" }, valuesAsStrings);
144+
form.AddField(choice);
145+
document.Close();
146+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
147+
}
148+
149+
[NUnit.Framework.Test]
150+
public virtual void CorruptedOptAndValueSetToNullTest() {
151+
String srcPdf = sourceFolder + "corruptedOptAndValueSetToNullTest.pdf";
152+
String outPdf = destinationFolder + "corruptedOptAndValueSetToNullTest.pdf";
153+
String cmpPdf = sourceFolder + "cmp_corruptedOptAndValueSetToNullTest.pdf";
154+
PdfDocument document = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
155+
PdfAcroForm form = PdfAcroForm.GetAcroForm(document, false);
156+
PdfChoiceFormField choice = (PdfChoiceFormField)form.GetField("choice");
157+
choice.SetListSelected(new String[] { null, "three" });
158+
document.Close();
159+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
160+
}
161+
162+
[NUnit.Framework.Test]
163+
[LogMessage(iText.IO.LogMessageConstant.FIELD_VALUE_IS_NOT_CONTAINED_IN_OPT_ARRAY)]
164+
public virtual void MultiSelectByValueRemoveIKeyTest() {
165+
String srcPdf = sourceFolder + "listWithPreselectedValue.pdf";
166+
String outPdf = destinationFolder + "selectByValueRemoveIKeyTest.pdf";
167+
String cmpPdf = sourceFolder + "cmp_selectByValueRemoveIKeyTest.pdf";
168+
String value = "zwei";
169+
PdfDocument document = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
170+
document.AddNewPage();
171+
PdfAcroForm form = PdfAcroForm.GetAcroForm(document, true);
172+
PdfFormField field = form.GetField("choice");
173+
field.SetValue(value);
174+
NUnit.Framework.Assert.IsNull(field.GetPdfObject().Get(PdfName.I));
175+
CompareTool compareTool = new CompareTool();
176+
NUnit.Framework.Assert.IsTrue(compareTool.CompareStrings(new PdfString(value), field.GetPdfObject().GetAsString
177+
(PdfName.V)));
178+
document.Close();
179+
NUnit.Framework.Assert.IsNull(compareTool.CompareByContent(outPdf, cmpPdf, destinationFolder));
180+
}
181+
182+
[NUnit.Framework.Test]
183+
public virtual void MultiSelectByIndexOutOfBoundsTest() {
184+
String srcPdf = sourceFolder + "multiSelectTest.pdf";
185+
String outPdf = destinationFolder + "multiSelectByIndexOutOfBoundsTest.pdf";
186+
String cmpPdf = sourceFolder + "cmp_multiSelectByIndexOutOfBoundsTest.pdf";
187+
PdfDocument document = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
188+
PdfAcroForm form = PdfAcroForm.GetAcroForm(document, false);
189+
PdfChoiceFormField field = (PdfChoiceFormField)form.GetField("choice");
190+
field.SetListSelected(new int[] { 5 });
191+
document.Close();
192+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
193+
}
194+
195+
[NUnit.Framework.Test]
196+
public virtual void NotInstanceOfPdfChoiceFormFieldTest() {
197+
String outPdf = destinationFolder + "notInstanceOfPdfChoiceFormFieldTest.pdf";
198+
String cmpPdf = sourceFolder + "cmp_notInstanceOfPdfChoiceFormFieldTest.pdf";
199+
PdfDocument document = new PdfDocument(new PdfWriter(outPdf));
200+
PdfPage page = document.AddNewPage();
201+
PdfAcroForm form = PdfAcroForm.GetAcroForm(document, true);
202+
PdfDictionary fieldDictionary = new PdfDictionary();
203+
fieldDictionary.Put(PdfName.FT, PdfName.Ch);
204+
PdfArray opt = new PdfArray();
205+
opt.Add(new PdfString("one", PdfEncodings.UNICODE_BIG));
206+
opt.Add(new PdfString("two", PdfEncodings.UNICODE_BIG));
207+
opt.Add(new PdfString("three", PdfEncodings.UNICODE_BIG));
208+
opt.Add(new PdfString("four", PdfEncodings.UNICODE_BIG));
209+
fieldDictionary.Put(PdfName.Opt, opt);
210+
fieldDictionary.Put(PdfName.P, page.GetPdfObject().GetIndirectReference());
211+
fieldDictionary.Put(PdfName.Rect, new PdfArray(new int[] { 330, 660, 380, 740 }));
212+
fieldDictionary.Put(PdfName.Subtype, PdfName.Widget);
213+
fieldDictionary.Put(PdfName.T, new PdfString("choice", PdfEncodings.UNICODE_BIG));
214+
fieldDictionary.MakeIndirect(document);
215+
PdfFormField field = new PdfFormField(fieldDictionary);
216+
field.SetValue("two");
217+
form.AddField(field);
218+
document.Close();
219+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
220+
}
221+
222+
[NUnit.Framework.Test]
223+
public virtual void TopIndexTest() {
224+
String srcPdf = sourceFolder + "choiceFieldNotFittingTest.pdf";
225+
String outPdf = destinationFolder + "topIndexTest.pdf";
226+
String cmpPdf = sourceFolder + "cmp_topIndexTest.pdf";
227+
PdfDocument document = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
228+
PdfAcroForm form = PdfAcroForm.GetAcroForm(document, false);
229+
PdfChoiceFormField field = (PdfChoiceFormField)form.GetField("choice");
230+
field.SetListSelected(new String[] { "seven" });
231+
int topIndex = field.GetIndices().GetAsNumber(0).IntValue();
232+
field.SetTopIndex(topIndex);
233+
document.Close();
234+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
235+
}
73236
}
74237
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ public static void BeforeClass() {
7171
CreateDestinationFolder(destinationFolder);
7272
}
7373

74+
[NUnit.Framework.Test]
75+
// The first message for the case when the FormField is null,
76+
// the second message when the FormField is a indirect reference to null.
77+
[LogMessage(iText.IO.LogMessageConstant.CANNOT_CREATE_FORMFIELD, Count = 2)]
78+
public virtual void NullFormFieldTest() {
79+
PdfDocument pdfDoc = new PdfDocument(new PdfReader(sourceFolder + "nullFormField.pdf"));
80+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
81+
pdfDoc.Close();
82+
}
83+
7484
[NUnit.Framework.Test]
7585
public virtual void FormFieldTest01() {
7686
PdfDocument pdfDoc = new PdfDocument(new PdfReader(sourceFolder + "formFieldFile.pdf"));
@@ -479,8 +489,8 @@ public virtual void FillFormWithDefaultResourcesUpdateFont() {
479489
PdfFormField field = fields.Get("Text1");
480490
field.SetFont(PdfFontFactory.CreateFont(StandardFonts.COURIER));
481491
field.SetValue("New value size must be 8, but with different font.");
482-
new Canvas(new PdfCanvas(pdfDoc.GetFirstPage()), pdfDoc, new Rectangle(30, 500, 500, 200)).Add(new Paragraph
483-
("The text font after modification it via PDF viewer (e.g. Acrobat) shall be preserved."));
492+
new Canvas(new PdfCanvas(pdfDoc.GetFirstPage()), new Rectangle(30, 500, 500, 200)).Add(new Paragraph("The text font after modification it via PDF viewer (e.g. Acrobat) shall be preserved."
493+
));
484494
pdfDoc.Close();
485495
CompareTool compareTool = new CompareTool();
486496
String errorMessage = compareTool.CompareByContent(outPdf, cmpPdf, destinationFolder, "diff_");
@@ -850,6 +860,7 @@ public virtual void WrapPrecedingContentOnFlattenTest() {
850860
}
851861

852862
[NUnit.Framework.Test]
863+
[LogMessage(iText.IO.LogMessageConstant.MULTIPLE_VALUES_ON_A_NON_MULTISELECT_FIELD)]
853864
public virtual void PdfWithDifferentFieldsTest() {
854865
String fileName = destinationFolder + "pdfWithDifferentFieldsTest.pdf";
855866
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(fileName));
@@ -1080,6 +1091,7 @@ public virtual void ChoiceFieldAutoSize01Test() {
10801091
}
10811092

10821093
[NUnit.Framework.Test]
1094+
[LogMessage(iText.IO.LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES)]
10831095
public virtual void ChoiceFieldAutoSize02Test() {
10841096
String filename = destinationFolder + "choiceFieldAutoSize02Test.pdf";
10851097
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(filename));

itext.tests/itext.forms.tests/itext/forms/xfa/XFAFormTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ source product.
4242
*/
4343
using System;
4444
using System.IO;
45+
using System.Xml;
46+
using System.Xml.Linq;
4547
using iText.Forms;
4648
using iText.Kernel.Pdf;
4749
using iText.Kernel.Utils;
@@ -129,5 +131,15 @@ public virtual void FindFieldNameWithoutDataSet() {
129131
String name = xfaForm.FindFieldName("TextField1");
130132
NUnit.Framework.Assert.IsNull(name);
131133
}
134+
135+
[NUnit.Framework.Test]
136+
public virtual void ExtractXFADataTest() {
137+
String src = sourceFolder + "xfaFormWithDataSet.pdf";
138+
PdfDocument pdfDocument = new PdfDocument(new PdfReader(src));
139+
XfaForm xfa = new XfaForm(pdfDocument);
140+
XElement node = (XElement) xfa.FindDatasetsNode("Number1");
141+
NUnit.Framework.Assert.IsNotNull(node);
142+
NUnit.Framework.Assert.AreEqual("Number1", node.Name.LocalName);
143+
}
132144
}
133145
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using System.Collections.Generic;
24+
using System.IO;
25+
using iText.Forms;
26+
using iText.Kernel.Pdf;
27+
using iText.Kernel.Pdf.Annot;
28+
using iText.Test;
29+
using iText.Test.Attributes;
30+
31+
namespace iText.Forms.Xfdf {
32+
public class XfdfReaderUnitTest : ExtendedITextTest {
33+
[NUnit.Framework.Test]
34+
[LogMessage(iText.IO.LogMessageConstant.XFDF_NO_F_OBJECT_TO_COMPARE)]
35+
public virtual void XfdfSquareAnnotationWithoutFringe() {
36+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new MemoryStream()));
37+
pdfDocument.AddNewPage();
38+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDocument, true);
39+
AnnotObject annotObject = new AnnotObject();
40+
annotObject.SetName(XfdfConstants.SQUARE);
41+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.PAGE, "1"));
42+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.RECT, "493.399638,559.179024,571.790235,600.679928"
43+
));
44+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.COLOR, "#000000"));
45+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.TITLE, "Guest"));
46+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.FLAGS, "print"));
47+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.DATE, "D:20200123110420-05'00'"));
48+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.NAME, "436b0463-41e6-d3fe-b660-c3764226615b"));
49+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.CREATION_DATE, "D:20200123110418-05'00'"));
50+
annotObject.AddAttribute(new AttributeObject(XfdfConstants.SUBJECT, "Rectangle"));
51+
AnnotsObject annotsObject = new AnnotsObject();
52+
annotsObject.AddAnnot(annotObject);
53+
XfdfObject xfdfObject = new XfdfObject();
54+
xfdfObject.SetAnnots(annotsObject);
55+
XfdfReader xfdfReader = new XfdfReader();
56+
xfdfReader.MergeXfdfIntoPdf(xfdfObject, pdfDocument, "smth");
57+
IList<PdfAnnotation> annotations = pdfDocument.GetPage(1).GetAnnotations();
58+
NUnit.Framework.Assert.IsNotNull(annotations);
59+
NUnit.Framework.Assert.AreEqual(1, annotations.Count);
60+
NUnit.Framework.Assert.AreEqual(PdfName.Square, annotations[0].GetSubtype());
61+
pdfDocument.Close();
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)