Skip to content

Commit 0d1c72d

Browse files
committed
[RELEASE] Merge branch 'release/5.5.13'
2 parents 3ca54cc + 5a41eb8 commit 0d1c72d

File tree

24 files changed

+331
-46
lines changed

24 files changed

+331
-46
lines changed

itext/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>itextpdf</artifactId>
13-
<version>5.5.12</version>
13+
<version>5.5.13</version>
1414

1515
<name>iText Core</name>
1616
<description>A Free Java-PDF library</description>

itext/src/main/java/com/itextpdf/text/Version.java

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ public final class Version {
7070
* This String contains the version number of this iText release.
7171
* For debugging purposes, we request you NOT to change this constant.
7272
*/
73-
private String release = "5.5.12";
73+
private String release = "5.5.13";
7474
/**
7575
* This String contains the iText version as shown in the producer line.
7676
* iText is a product developed by iText Group NV.
7777
* iText Group requests that you retain the iText producer line
7878
* in every PDF that is created or manipulated using iText.
7979
*/
80-
private String iTextVersion = iText + " " + release + " \u00a92000-2017 iText Group NV";
80+
private String iTextVersion = iText + " " + release + " \u00a92000-2018 iText Group NV";
8181
/**
8282
* The license key.
8383
*/
@@ -93,46 +93,51 @@ public static Version getInstance() {
9393
version = new Version();
9494
synchronized ( version ) {
9595
try {
96-
Class<?> klass = Class.forName("com.itextpdf.license.LicenseKey");
97-
Method m = klass.getMethod("getLicenseeInfo");
98-
String[] info = (String[])m.invoke(klass.newInstance());
99-
if (info[3] != null && info[3].trim().length() > 0) {
100-
version.key = info[3];
101-
} else {
102-
version.key = "Trial version ";
103-
if (info[5] == null) {
104-
version.key += "unauthorised";
96+
Class<?> klass = Class.forName("com.itextpdf.licensekey.LicenseKey");
97+
if(klass != null) {
98+
Class[] cArg = {String.class};
99+
Method m = klass.getMethod("getLicenseeInfoForVersion",cArg);
100+
Object[] args = {version.release};
101+
String[] info = (String[]) m.invoke(klass.newInstance(),args);
102+
if (info[3] != null && info[3].trim().length() > 0) {
103+
version.key = info[3];
105104
} else {
106-
version.key += info[5];
105+
version.key = "Trial version ";
106+
if (info[5] == null) {
107+
version.key += "unauthorised";
108+
} else {
109+
version.key += info[5];
110+
}
107111
}
108-
}
109112

110-
if (info[4] != null && info[4].trim().length() > 0) {
111-
version.iTextVersion = info[4];
112-
} else if (info[2] != null && info[2].trim().length() > 0) {
113-
version.iTextVersion += " (" + info[2];
114-
if (!version.key.toLowerCase().startsWith("trial")) {
115-
version.iTextVersion += "; licensed version)";
116-
} else {
117-
version.iTextVersion += "; " + version.key + ")";
118-
}
119-
} else if (info[0] != null && info[0].trim().length() > 0) {
120-
// fall back to contact name, if company name is unavailable
121-
version.iTextVersion += " (" + info[0];
122-
if (!version.key.toLowerCase().startsWith("trial")) {
123-
// we shouldn't have a licensed version without company name,
124-
// but let's account for it anyway
125-
version.iTextVersion += "; licensed version)";
113+
if (info[4] != null && info[4].trim().length() > 0) {
114+
version.iTextVersion = info[4];
115+
} else if (info[2] != null && info[2].trim().length() > 0) {
116+
version.iTextVersion += " (" + info[2];
117+
if (!version.key.toLowerCase().startsWith("trial")) {
118+
version.iTextVersion += "; licensed version)";
119+
} else {
120+
version.iTextVersion += "; " + version.key + ")";
121+
}
122+
} else if (info[0] != null && info[0].trim().length() > 0) {
123+
// fall back to contact name, if company name is unavailable
124+
version.iTextVersion += " (" + info[0];
125+
if (!version.key.toLowerCase().startsWith("trial")) {
126+
// we shouldn't have a licensed version without company name,
127+
// but let's account for it anyway
128+
version.iTextVersion += "; licensed version)";
129+
} else {
130+
version.iTextVersion += "; " + version.key + ")";
131+
}
126132
} else {
127-
version.iTextVersion += "; " + version.key + ")";
133+
throw new Exception();
128134
}
129-
} else {
130-
throw new Exception();
131135
}
132136
} catch (Exception e) {
133137
version.iTextVersion += AGPL;
134138
}
135139
}
140+
136141
}
137142
return version;
138143
}

itext/src/main/java/com/itextpdf/text/pdf/BarcodePDF417.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ else if (codeRows > 90) {
860860
pad = tot - lenErr - lenCodewords;
861861
if ((options & PDF417_USE_MACRO) != 0) {
862862
// the padding comes before the control block
863-
System.arraycopy(codewords, macroIndex, codewords, macroIndex + pad, pad);
863+
System.arraycopy(codewords, macroIndex, codewords, macroIndex + pad, lenCodewords - macroIndex);
864864
cwPtr = lenCodewords + pad;
865865
while (pad-- != 0)
866866
codewords[macroIndex++] = TEXT_MODE;

itext/src/main/java/com/itextpdf/text/pdf/PdfStamperImp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ protected void flatFields() {
10121012
markUsed(stream);
10131013
}
10141014
}
1015-
} else if (appDic != null && as_n != null) {
1015+
} else if (appDic != null && as_n != null && (as_n.isStream() || as_n.isDictionary())) {
10161016
PdfArray bbox = ((PdfDictionary) as_n).getAsArray(PdfName.BBOX);
10171017
PdfArray rect = merged.getAsArray(PdfName.RECT);
10181018
if (bbox != null && rect != null) {

itext/src/main/java/com/itextpdf/text/pdf/codec/PngImage.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ PdfObject getColorspace() {
515515

516516
Image getImage() throws IOException {
517517
readPng();
518+
checkIccProfile();
518519
try {
519520
int pal0 = 0;
520521
int palIdx = 0;
@@ -875,6 +876,21 @@ int[] getPixel(byte curr[]) {
875876
}
876877
}
877878
}
879+
880+
private int getExpectedIccNumberOfComponents() {
881+
if (colorType == 0 || colorType == 4) {
882+
return 1;
883+
} else {
884+
return 3;
885+
}
886+
}
887+
888+
private void checkIccProfile() {
889+
if (icc_profile != null && icc_profile.getNumComponents() != getExpectedIccNumberOfComponents()) {
890+
LoggerFactory.getLogger(getClass()).warn(MessageLocalization.getComposedMessage("unexpected.color.space.in.embedded.icc.profile"));
891+
icc_profile = null;
892+
}
893+
}
878894

879895
private static void decodeSubFilter(byte[] curr, int count, int bpp) {
880896
for (int i = bpp; i < count; i++) {

itext/src/main/resources/com/itextpdf/text/l10n/error/en.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ path.construction.operator.inside.text.object=Path construction or drawing opera
514514
unbalanced.layer.operators=Unbalanced layer operators.
515515
unbalanced.marked.content.operators=Unbalanced marked content operators.
516516
unbalanced.save.restore.state.operators=Unbalanced save/restore state operators.
517+
unexpected.color.space.in.embedded.icc.profile=Unexpected color space in embedded ICC Profile. It will be ignored.
517518
unexpected.end.of.file=Unexpected end of file.
518519
unexpected.eof=Unexpected EOF
519520
unexpected.gt.gt=Unexpected '>>'

itext/src/main/resources/com/itextpdf/text/l10n/error/nl.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ path.construction.operator.inside.text.object=Pad constructie of drawing operato
514514
unbalanced.layer.operators=Ongebalanceerde operatoren voor layers.
515515
unbalanced.marked.content.operators=Ongebalanceerde marked content operatoren.
516516
unbalanced.save.restore.state.operators=Ongebalanceerde save/restore state operatoren.
517+
unexpected.color.space.in.embedded.icc.profile=Onverwachte kleurenruimte in ingesloten ICC-profiel. Het zal worden genegeerd.
517518
unexpected.end.of.file=Onverwacht einde van het bestand.
518519
unexpected.eof=Onverwachte EOF
519520
unexpected.gt.gt=Onverwachte '>>'

itext/src/test/java/com/itextpdf/text/pdf/AcroFieldsTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import org.junit.Assert;
5151
import org.junit.Before;
5252
import org.junit.Test;
53-
import org.w3c.dom.css.RGBColor;
5453

5554
import java.io.*;
5655
import java.util.HashMap;
@@ -79,7 +78,7 @@ public void testSetFields() throws Exception {
7978
public void testListInSetFields() throws Exception {
8079
singleTest("list_register.xfdf");
8180
}
82-
81+
8382
private void singleTest(String xfdfResourceName) throws Exception {
8483
// merging the FDF file
8584
PdfReader pdfreader = TestResourceUtils.getResourceAsPdfReader(this, "SimpleRegistrationForm.pdf");
@@ -93,15 +92,15 @@ private void singleTest(String xfdfResourceName) throws Exception {
9392

9493
private final String PDF_COMBO = "./src/test/resources/com/itextpdf/text/pdf/AcroFieldsTest/choice_field_order.pdf";
9594
private final String PDF_COMBO_EXPORT = "./src/test/resources/com/itextpdf/text/pdf/AcroFieldsTest/choice_field_order_export.pdf";
96-
95+
9796
private final String PDF_COMBO_FIELD_NAME = "choice_field";
98-
97+
9998
private final String[] PDF_COMBO_VALUES = {
10099
"Option 1",
101100
"Option 2",
102101
"Option 3"
103102
};
104-
103+
105104
private final String[] PDF_COMBO_EXPORT_VALUES = {
106105
"Export 1",
107106
"Export 2",
@@ -150,7 +149,7 @@ public void testComboboxExportValues() {
150149
Assert.fail(e.getMessage());
151150
}
152151
}
153-
152+
154153
private void checkOrderOfAppearanceStates(String pdf, String fieldName, String[] expected) throws IOException {
155154
PdfReader reader = new PdfReader(pdf);
156155
AcroFields acroFields = reader.getAcroFields();
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
package com.itextpdf.text.pdf;
44+
45+
import com.itextpdf.testutils.CompareTool;
46+
import com.itextpdf.testutils.ITextTest;
47+
import com.itextpdf.text.BadElementException;
48+
import com.itextpdf.text.BaseColor;
49+
import com.itextpdf.text.Document;
50+
import com.itextpdf.text.Image;
51+
import com.itextpdf.text.Paragraph;
52+
import com.itextpdf.text.Rectangle;
53+
import org.junit.Assert;
54+
import org.junit.Before;
55+
import org.junit.Test;
56+
57+
import java.io.File;
58+
import java.io.FileOutputStream;
59+
60+
public class BarcodeMacroPDF417Test extends ITextTest {
61+
62+
private static final String CMP_DIR = "./src/test/resources/com/itextpdf/text/pdf/BarcodeMacroPDF417Test/";
63+
private static final String OUT_DIR = "./target/com/itextpdf/test/pdf/BarcodeMacroPDF417Test/";
64+
65+
@Before
66+
public void setUp() {
67+
new File(OUT_DIR).mkdirs();
68+
}
69+
70+
@Override
71+
protected void makePdf(String outPdf) throws Exception {
72+
Document document = new Document();
73+
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outPdf));
74+
document.open();
75+
PdfContentByte cb = writer.getDirectContent();
76+
Image img = createBarcode(cb, "This is PDF417 segment 0", 1, 1, 0);
77+
document.add(new Paragraph("This is PDF417 segment 0"));
78+
document.add(img);
79+
80+
document.add(new Paragraph("\u00a0"));
81+
document.add(new Paragraph("\u00a0"));
82+
document.add(new Paragraph("\u00a0"));
83+
document.add(new Paragraph("\u00a0"));
84+
document.add(new Paragraph("\u00a0"));
85+
document.add(new Paragraph("\u00a0"));
86+
document.add(new Paragraph("\u00a0"));
87+
document.add(new Paragraph("\u00a0"));
88+
89+
img = createBarcode(cb, "This is PDF417 segment 1", 1, 1, 1);
90+
document.add(new Paragraph("This is PDF417 segment 1"));
91+
document.add(img);
92+
document.close();
93+
}
94+
95+
public Image createBarcode(PdfContentByte cb, String text, float mh, float mw, int segmentId) throws BadElementException {
96+
BarcodePDF417 pf = new BarcodePDF417();
97+
98+
// MacroPDF417 setup
99+
pf.setOptions(BarcodePDF417.PDF417_USE_MACRO);
100+
pf.setMacroFileId("12");
101+
pf.setMacroSegmentCount(2);
102+
pf.setMacroSegmentId(segmentId);
103+
104+
pf.setText(text);
105+
Rectangle size = pf.getBarcodeSize();
106+
PdfTemplate template = cb.createTemplate(mw * size.getWidth(), mh * size.getHeight());
107+
pf.placeBarcode(template, BaseColor.BLACK, mh, mw);
108+
return Image.getInstance(template);
109+
}
110+
111+
@Test
112+
public void test() throws Exception {
113+
runTest();
114+
}
115+
116+
@Override
117+
protected void comparePdf(String outPdf, String cmpPdf) throws Exception {
118+
// compare
119+
CompareTool compareTool = new CompareTool();
120+
String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, OUT_DIR, "diff");
121+
if (errorMessage != null) {
122+
Assert.fail(errorMessage);
123+
}
124+
}
125+
126+
@Override
127+
protected String getOutPdf() {
128+
return OUT_DIR + "barcode_macro_pdf417.pdf";
129+
}
130+
131+
@Override
132+
protected String getCmpPdf() {
133+
return CMP_DIR + "cmp_barcode_macro_pdf417.pdf";
134+
}
135+
}

0 commit comments

Comments
 (0)