Skip to content

Commit

Permalink
[RELEASE] iText 7 Core - 7.0.7
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
iText-CI committed Apr 12, 2018
2 parents dcb33bd + a29f976 commit 0070b69
Show file tree
Hide file tree
Showing 48 changed files with 385 additions and 141 deletions.
2 changes: 1 addition & 1 deletion barcodes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.0.6</version>
<version>7.0.7</version>
</parent>

<artifactId>barcodes</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion font-asian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.0.6</version>
<version>7.0.7</version>
</parent>

<artifactId>font-asian</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion forms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.0.6</version>
<version>7.0.7</version>
</parent>

<artifactId>forms</artifactId>
Expand Down
10 changes: 4 additions & 6 deletions forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ This file is part of the iText (R) project.
import com.itextpdf.kernel.pdf.PdfBoolean;
import com.itextpdf.kernel.pdf.PdfDictionary;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfIndirectReference;
import com.itextpdf.kernel.pdf.PdfName;
import com.itextpdf.kernel.pdf.PdfNumber;
import com.itextpdf.kernel.pdf.PdfObject;
Expand All @@ -65,6 +64,8 @@ This file is part of the iText (R) project.
import com.itextpdf.kernel.pdf.tagutils.TagReference;
import com.itextpdf.kernel.pdf.tagutils.TagTreePointer;
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class represents the static form technology AcroForm on a PDF file.
*/
Expand Down Expand Up @@ -129,7 +127,6 @@ public class PdfAcroForm extends PdfObjectWrapper<PdfDictionary> {
*/
protected PdfDocument document;

Logger logger = LoggerFactory.getLogger(PdfAcroForm.class);
private static PdfName[] resourceNames = {PdfName.Font, PdfName.XObject, PdfName.ColorSpace, PdfName.Pattern};
private PdfDictionary defaultResources;
private Set<PdfFormField> fieldsForFlattening = new LinkedHashSet<>();
Expand Down Expand Up @@ -178,7 +175,6 @@ public static PdfAcroForm getAcroForm(PdfDocument document, boolean createIfNotE
acroForm.makeIndirect(document);
document.getCatalog().put(PdfName.AcroForm, acroForm.getPdfObject());
document.getCatalog().setModified();
acroForm.setDefaultAppearance("/Helv 0 Tf 0 g ");
}
} else {
acroForm = new PdfAcroForm(acroFormDictionary, document);
Expand Down Expand Up @@ -839,6 +835,7 @@ public void replaceField(String name, PdfFormField field) {
protected PdfArray getFields() {
PdfArray fields = getPdfObject().getAsArray(PdfName.Fields);
if (fields == null) {
Logger logger = LoggerFactory.getLogger(PdfAcroForm.class);
logger.warn(LogMessageConstant.NO_FIELDS_IN_ACROFORM);
fields = new PdfArray();
getPdfObject().put(PdfName.Fields, fields);
Expand All @@ -855,6 +852,7 @@ private Map<String, PdfFormField> iterateFields(PdfArray array, Map<String, PdfF
int index = 1;
for (PdfObject field : array) {
if (field.isFlushed()) {
Logger logger = LoggerFactory.getLogger(PdfAcroForm.class);
logger.warn(LogMessageConstant.FORM_FIELD_WAS_FLUSHED);
continue;
}
Expand Down
28 changes: 19 additions & 9 deletions forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,10 @@ public PdfString getDefaultAppearance() {
}
}
}
// DA is an inherited key, therefore AcroForm shall be checked if there is no parent or no DA in parent.
if (defaultAppearance == null) {
defaultAppearance = (PdfString) getAcroFormKey(PdfName.DA, PdfObject.STRING);
}
return defaultAppearance;
}

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


/**
* Gets a code specifying the form of quadding (justification) to be used in displaying the text:
* 0 Left-justified
Expand Down Expand Up @@ -1885,9 +1890,7 @@ public boolean regenerateField() {
if (appearance == null) {
appearance = new PdfFormXObject(new Rectangle(0, 0, bBox.toRectangle().getWidth(), bBox.toRectangle().getHeight()));
}
if (matrix != null) {
appearance.put(PdfName.Matrix, matrix);
}
appearance.put(PdfName.Matrix, matrix);
//Create text appearance
if (PdfName.Tx.equals(type)) {
if (!isMultiline()) {
Expand Down Expand Up @@ -2007,6 +2010,18 @@ public boolean regenerateField() {
return true;
}

private PdfObject getAcroFormKey(PdfName key, int type) {
PdfObject acroFormKey = null;
PdfDocument document = getDocument();
if (document != null) {
PdfDictionary acroFormDictionary = document.getCatalog().getPdfObject().getAsDictionary(PdfName.AcroForm);
if (acroFormDictionary != null) {
acroFormKey = acroFormDictionary.get(key);
}
}
return (acroFormKey != null && acroFormKey.getType() == type) ? acroFormKey : null;
}

/**
* According to spec (ISO-32000-1, 12.7.3.3) zero font size should interpretaded as auto size.
*/
Expand Down Expand Up @@ -2464,12 +2479,7 @@ protected Object[] getFontAndSize(PdfDictionary asNormal) throws IOException {
PdfDictionary normalResources = null;
PdfDictionary defaultResources = null;
PdfDocument document = getDocument();
if (document != null) {
PdfDictionary acroformDictionary = document.getCatalog().getPdfObject().getAsDictionary(PdfName.AcroForm);
if (acroformDictionary != null) {
defaultResources = acroformDictionary.getAsDictionary(PdfName.DR);
}
}
defaultResources = (PdfDictionary) getAcroFormKey(PdfName.DR, PdfObject.DICTIONARY);
if (asNormal != null) {
normalResources = asNormal.getAsDictionary(PdfName.Resources);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ public void formFlatteningTest01() throws IOException, InterruptedException {

doc.close();

CompareTool compareTool = new CompareTool();
String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_formFlatteningTest01.pdf", destinationFolder, "diff_");
if (errorMessage != null) {
Assert.fail(errorMessage);
}
Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_formFlatteningTest01.pdf", destinationFolder, "diff_"));
}

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

doc.close();

CompareTool compareTool = new CompareTool();
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
if (errorMessage != null) {
Assert.fail(errorMessage);
}
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
}

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

doc.close();

CompareTool compareTool = new CompareTool();
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
if (errorMessage != null) {
Assert.fail(errorMessage);
}
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
}

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

doc.close();

CompareTool compareTool = new CompareTool();
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
if (errorMessage != null) {
Assert.fail(errorMessage);
}
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
}

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

doc.close();

CompareTool compareTool = new CompareTool();
String errorMessage = compareTool.compareByContent(dest, cmp, destinationFolder, "diff_");
if (errorMessage != null) {
Assert.fail(errorMessage);
}
Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_"));
}

}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion hyph/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.0.6</version>
<version>7.0.7</version>
</parent>

<artifactId>hyph</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.0.6</version>
<version>7.0.7</version>
</parent>

<artifactId>io</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion io/src/main/java/com/itextpdf/io/image/GifImageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private static void readFrame(GifParameters gif) throws java.io.IOException {
colorspace[3] = PdfEncodings.convertToString(gif.m_curr_table, null);
Map<String, Object> ad = new HashMap<>();
ad.put("ColorSpace", colorspace);
RawImageData img = new RawImageData(gif.m_out, ImageType.NONE);
RawImageData img = new RawImageData(gif.m_out, ImageType.GIF);
RawImageHelper.updateRawImageParameters(img, gif.iw, gif.ih, 1, gif.m_bpc, gif.m_out);
RawImageHelper.updateImageAttributes(img, ad);
gif.image.addFrame(img);
Expand Down
10 changes: 10 additions & 0 deletions io/src/main/java/com/itextpdf/io/util/UrlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,14 @@ public static URL getFinalURL(URL url) throws IOException {
}
return url;
}

/**
* This method gets uri string from a file.
* @param filename a given filename
* @return a uri string
*/
public static String getFileUriString(String filename) throws MalformedURLException {
return new File(filename).toURI().toURL().toExternalForm();
}

}
67 changes: 67 additions & 0 deletions io/src/test/java/com/itextpdf/io/image/GifTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2018 iText Group NV
Authors: iText Software.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation with the addition of the
following permission added to Section 15 as permitted in Section 7(a):
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
OF THIRD PARTY RIGHTS
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, see http://www.gnu.org/licenses or write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA, 02110-1301 USA, or download the license from the following URL:
http://itextpdf.com/terms-of-use/
The interactive user interfaces in modified source and object code versions
of this program must display Appropriate Legal Notices, as required under
Section 5 of the GNU Affero General Public License.
In accordance with Section 7(b) of the GNU Affero General Public License,
a covered work must retain the producer line in every PDF that is created
or manipulated using iText.
You can be released from the requirements of the license by purchasing
a commercial license. Buying such a license is mandatory as soon as you
develop commercial activities involving the iText software without
disclosing the source code of your own applications.
These activities include: offering paid services to customers as an ASP,
serving PDFs on the fly in a web application, shipping iText with a closed
source product.
For more information, please contact iText Software Corp. at this
address: [email protected]
*/
package com.itextpdf.io.image;

import com.itextpdf.io.util.StreamUtil;
import com.itextpdf.test.annotations.type.UnitTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.io.FileInputStream;
import java.io.IOException;

@Category(UnitTest.class)
public class GifTest {
public static final String sourceFolder = "./src/test/resources/com/itextpdf/io/image/";

@Test
public void gifImageTest() throws IOException {
try (FileInputStream file = new FileInputStream(sourceFolder + "WP_20140410_001.gif")) {
byte[] fileContent = StreamUtil.inputStreamToArray(file);
ImageData img = ImageDataFactory.create(fileContent, false);
Assert.assertTrue(img.isRawImage());
Assert.assertEquals(ImageType.GIF, img.getOriginalType());
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion itextcore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.itextpdf</groupId>
<artifactId>itext7-core</artifactId>
<version>7.0.6</version>
<version>7.0.7</version>
<packaging>pom</packaging>

<name>iText 7 Core</name>
Expand Down
2 changes: 1 addition & 1 deletion kernel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.0.6</version>
<version>7.0.7</version>
</parent>

<artifactId>kernel</artifactId>
Expand Down
1 change: 1 addition & 0 deletions kernel/src/main/java/com/itextpdf/kernel/PdfException.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public class PdfException extends RuntimeException {
public static final String ColorSpaceNotFound = "ColorSpace not found.";
public static final String ContentStreamMustNotInvokeOperatorsThatSpecifyColorsOrOtherColorRelatedParameters = "Content stream must not invoke operators that specify colors or other color related parameters in the graphics state.";
public static final String DecodeParameterType1IsNotSupported = "Decode parameter type {0} is not supported.";
public static final String DefaultAppearanceNotFound = "DefaultAppearance is required but not found";
public static final String DefaultcryptfilterNotFoundEncryption = "/DefaultCryptFilter not found (encryption).";
public static final String DictionaryKey1IsNotAName = "Dictionary key {0} is not a name.";
@Deprecated
Expand Down
Loading

0 comments on commit 0070b69

Please sign in to comment.