Skip to content

Commit 0070b69

Browse files
committed
[RELEASE] iText 7 Core - 7.0.7
https://github.com/itext/itext7/releases/tag/7.0.7 * release/7.0.7: Remove jgitflow plugin from POM file [RELEASE] 7.0.7-SNAPSHOT -> 7.0.7 Add new util method. Add another problematic xmp test Remove problematic metadata from form test and add test for it Remove default appearance from AcroForm. Forms. Fix issue with inherited default appearance Update xmp metadata if it was present in document before close Compare producer line on document info comparison Don't loop through initial indirects in compare tool Fix synchronization issues during version creation added category to test DEVSIX-1816 GifTest: close file stream Update compare tool to support new xml autoport mappings add test files after reverting of 7.0 GIF frames are of ImageType GIF Revert "GIF frames are of ImageType GIF" Revert "Add test/test resource to GifImageHelper" Add test/test resource to GifImageHelper Add test/test resource to GifImageHelper Add test/test resource to GifImageHelper GIF frames are of ImageType GIF fix broken test by correcting off-by-one error in RegexBasedLocationExtractionStrategy Add missing copyright headers correct off-by-one mistake in RegexBasedLocationExtractionStrategy Added new constant to PdfException. DefaultAppearanceNotFound. DEVSIX-1769 [RELEASE] 7.0.6-SNAPSHOT -> 7.0.7-SNAPSHOT Guard against NPE in CrlClientOnline Signed-off-by: iText Software (Community) <[email protected]>
2 parents dcb33bd + a29f976 commit 0070b69

File tree

48 files changed

+385
-141
lines changed

Some content is hidden

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

48 files changed

+385
-141
lines changed

barcodes/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.itextpdf</groupId>
77
<artifactId>root</artifactId>
8-
<version>7.0.6</version>
8+
<version>7.0.7</version>
99
</parent>
1010

1111
<artifactId>barcodes</artifactId>

font-asian/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.itextpdf</groupId>
77
<artifactId>root</artifactId>
8-
<version>7.0.6</version>
8+
<version>7.0.7</version>
99
</parent>
1010

1111
<artifactId>font-asian</artifactId>

forms/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.itextpdf</groupId>
77
<artifactId>root</artifactId>
8-
<version>7.0.6</version>
8+
<version>7.0.7</version>
99
</parent>
1010

1111
<artifactId>forms</artifactId>

forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ This file is part of the iText (R) project.
5252
import com.itextpdf.kernel.pdf.PdfBoolean;
5353
import com.itextpdf.kernel.pdf.PdfDictionary;
5454
import com.itextpdf.kernel.pdf.PdfDocument;
55-
import com.itextpdf.kernel.pdf.PdfIndirectReference;
5655
import com.itextpdf.kernel.pdf.PdfName;
5756
import com.itextpdf.kernel.pdf.PdfNumber;
5857
import com.itextpdf.kernel.pdf.PdfObject;
@@ -65,6 +64,8 @@ This file is part of the iText (R) project.
6564
import com.itextpdf.kernel.pdf.tagutils.TagReference;
6665
import com.itextpdf.kernel.pdf.tagutils.TagTreePointer;
6766
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
67+
import org.slf4j.Logger;
68+
import org.slf4j.LoggerFactory;
6869

6970
import java.util.ArrayList;
7071
import java.util.Arrays;
@@ -74,9 +75,6 @@ This file is part of the iText (R) project.
7475
import java.util.Map;
7576
import java.util.Set;
7677

77-
import org.slf4j.Logger;
78-
import org.slf4j.LoggerFactory;
79-
8078
/**
8179
* This class represents the static form technology AcroForm on a PDF file.
8280
*/
@@ -129,7 +127,6 @@ public class PdfAcroForm extends PdfObjectWrapper<PdfDictionary> {
129127
*/
130128
protected PdfDocument document;
131129

132-
Logger logger = LoggerFactory.getLogger(PdfAcroForm.class);
133130
private static PdfName[] resourceNames = {PdfName.Font, PdfName.XObject, PdfName.ColorSpace, PdfName.Pattern};
134131
private PdfDictionary defaultResources;
135132
private Set<PdfFormField> fieldsForFlattening = new LinkedHashSet<>();
@@ -178,7 +175,6 @@ public static PdfAcroForm getAcroForm(PdfDocument document, boolean createIfNotE
178175
acroForm.makeIndirect(document);
179176
document.getCatalog().put(PdfName.AcroForm, acroForm.getPdfObject());
180177
document.getCatalog().setModified();
181-
acroForm.setDefaultAppearance("/Helv 0 Tf 0 g ");
182178
}
183179
} else {
184180
acroForm = new PdfAcroForm(acroFormDictionary, document);
@@ -839,6 +835,7 @@ public void replaceField(String name, PdfFormField field) {
839835
protected PdfArray getFields() {
840836
PdfArray fields = getPdfObject().getAsArray(PdfName.Fields);
841837
if (fields == null) {
838+
Logger logger = LoggerFactory.getLogger(PdfAcroForm.class);
842839
logger.warn(LogMessageConstant.NO_FIELDS_IN_ACROFORM);
843840
fields = new PdfArray();
844841
getPdfObject().put(PdfName.Fields, fields);
@@ -855,6 +852,7 @@ private Map<String, PdfFormField> iterateFields(PdfArray array, Map<String, PdfF
855852
int index = 1;
856853
for (PdfObject field : array) {
857854
if (field.isFlushed()) {
855+
Logger logger = LoggerFactory.getLogger(PdfAcroForm.class);
858856
logger.warn(LogMessageConstant.FORM_FIELD_WAS_FLUSHED);
859857
continue;
860858
}

forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,10 @@ public PdfString getDefaultAppearance() {
14971497
}
14981498
}
14991499
}
1500+
// DA is an inherited key, therefore AcroForm shall be checked if there is no parent or no DA in parent.
1501+
if (defaultAppearance == null) {
1502+
defaultAppearance = (PdfString) getAcroFormKey(PdfName.DA, PdfObject.STRING);
1503+
}
15001504
return defaultAppearance;
15011505
}
15021506

@@ -1518,6 +1522,7 @@ public PdfFormField setDefaultAppearance(String defaultAppearance) {
15181522
return this;
15191523
}
15201524

1525+
15211526
/**
15221527
* Gets a code specifying the form of quadding (justification) to be used in displaying the text:
15231528
* 0 Left-justified
@@ -1885,9 +1890,7 @@ public boolean regenerateField() {
18851890
if (appearance == null) {
18861891
appearance = new PdfFormXObject(new Rectangle(0, 0, bBox.toRectangle().getWidth(), bBox.toRectangle().getHeight()));
18871892
}
1888-
if (matrix != null) {
1889-
appearance.put(PdfName.Matrix, matrix);
1890-
}
1893+
appearance.put(PdfName.Matrix, matrix);
18911894
//Create text appearance
18921895
if (PdfName.Tx.equals(type)) {
18931896
if (!isMultiline()) {
@@ -2007,6 +2010,18 @@ public boolean regenerateField() {
20072010
return true;
20082011
}
20092012

2013+
private PdfObject getAcroFormKey(PdfName key, int type) {
2014+
PdfObject acroFormKey = null;
2015+
PdfDocument document = getDocument();
2016+
if (document != null) {
2017+
PdfDictionary acroFormDictionary = document.getCatalog().getPdfObject().getAsDictionary(PdfName.AcroForm);
2018+
if (acroFormDictionary != null) {
2019+
acroFormKey = acroFormDictionary.get(key);
2020+
}
2021+
}
2022+
return (acroFormKey != null && acroFormKey.getType() == type) ? acroFormKey : null;
2023+
}
2024+
20102025
/**
20112026
* According to spec (ISO-32000-1, 12.7.3.3) zero font size should interpretaded as auto size.
20122027
*/
@@ -2464,12 +2479,7 @@ protected Object[] getFontAndSize(PdfDictionary asNormal) throws IOException {
24642479
PdfDictionary normalResources = null;
24652480
PdfDictionary defaultResources = null;
24662481
PdfDocument document = getDocument();
2467-
if (document != null) {
2468-
PdfDictionary acroformDictionary = document.getCatalog().getPdfObject().getAsDictionary(PdfName.AcroForm);
2469-
if (acroformDictionary != null) {
2470-
defaultResources = acroformDictionary.getAsDictionary(PdfName.DR);
2471-
}
2472-
}
2482+
defaultResources = (PdfDictionary) getAcroFormKey(PdfName.DR, PdfObject.DICTIONARY);
24732483
if (asNormal != null) {
24742484
normalResources = asNormal.getAsDictionary(PdfName.Resources);
24752485
}

forms/src/test/java/com/itextpdf/forms/FormFieldFlatteningTest.java

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ public void formFlatteningTest01() throws IOException, InterruptedException {
7979

8080
doc.close();
8181

82-
CompareTool compareTool = new CompareTool();
83-
String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_formFlatteningTest01.pdf", destinationFolder, "diff_");
84-
if (errorMessage != null) {
85-
Assert.fail(errorMessage);
86-
}
82+
Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_formFlatteningTest01.pdf", destinationFolder, "diff_"));
8783
}
8884

8985
@Test
@@ -105,11 +101,7 @@ public void formFlatteningTest_DefaultAppearanceGeneration_Rot0() throws IOExcep
105101

106102
doc.close();
107103

108-
CompareTool compareTool = new CompareTool();
109-
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
110-
if (errorMessage != null) {
111-
Assert.fail(errorMessage);
112-
}
104+
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
113105
}
114106

115107
}
@@ -133,11 +125,7 @@ public void formFlatteningTest_DefaultAppearanceGeneration_Rot90() throws IOExce
133125

134126
doc.close();
135127

136-
CompareTool compareTool = new CompareTool();
137-
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
138-
if (errorMessage != null) {
139-
Assert.fail(errorMessage);
140-
}
128+
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
141129
}
142130

143131
}
@@ -161,11 +149,7 @@ public void formFlatteningTest_DefaultAppearanceGeneration_Rot180() throws IOExc
161149

162150
doc.close();
163151

164-
CompareTool compareTool = new CompareTool();
165-
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
166-
if (errorMessage != null) {
167-
Assert.fail(errorMessage);
168-
}
152+
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
169153
}
170154

171155
}
@@ -189,12 +173,7 @@ public void formFlatteningTest_DefaultAppearanceGeneration_Rot270() throws IOExc
189173

190174
doc.close();
191175

192-
CompareTool compareTool = new CompareTool();
193-
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
194-
if (errorMessage != null) {
195-
Assert.fail(errorMessage);
196-
}
176+
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
197177
}
198-
199178
}
200179
}

0 commit comments

Comments
 (0)