Skip to content

Commit 957b001

Browse files
committed
[RELEASE] merging 'release/7.0.1' into 'master'
2 parents ed042f3 + d85f0bc commit 957b001

File tree

1,015 files changed

+20846
-8466
lines changed

Some content is hidden

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

1,015 files changed

+20846
-8466
lines changed

BUILDING.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,34 @@ To build iText 7, [Maven][1] must be installed.
22

33
Running install without a profile will generate the iText 7 jars:
44
```bash
5-
$ mvn clean install -Dmaven.test.skip=true | tee mvn.log
5+
$ mvn clean install \
6+
-Dmaven.test.skip=true \
7+
-Dmaven.javadoc.failOnError=false \
8+
| tee mvn.log
69
```
710

811
To run the tests, [Ghostscript][2] and [Imagemagick][3] must be installed.
912
```bash
10-
$ mvn clean install -Dmaven.test.failure.ignore=false -DgsExec=$(which gs) -DcompareExec=$(which compare) | tee mvn.log
13+
$ mvn clean install \
14+
-Dmaven.test.failure.ignore=false \
15+
-DgsExec=$(which gs) \
16+
-DcompareExec=$(which compare) \
17+
-Dmaven.javadoc.failOnError=false \
18+
| tee mvn.log
1119
```
1220

1321
You can use the supplied `Vagrantfile` to get a [Vagrant][4] VM ([Ubuntu][5] 14.04 LTS - Trusty Tahr, with [VirtualBox][6]) with all the required software installed.
1422
```bash
1523
$ vagrant box add ubuntu/trusty64
1624
$ vagrant up
17-
$ vagrant ssh -- 'cd /vagrant ; mvn clean install -Dmaven.test.skip=true' | tee mvn.log
25+
$ vagrant ssh -- \
26+
'cd /vagrant ; mvn clean install -Dmaven.test.skip=true -Dmaven.javadoc.failOnError=false' \
27+
| tee mvn.log
1828
```
1929

2030
[1]: http://maven.apache.org/
2131
[2]: http://www.ghostscript.com/
2232
[3]: http://www.imagemagick.org/
2333
[4]: https://www.vagrantup.com/
2434
[5]: http://www.ubuntu.com/
25-
[6]: https://www.virtualbox.org/
35+
[6]: https://www.virtualbox.org/

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.0</version>
8+
<version>7.0.1</version>
99
</parent>
1010

1111
<artifactId>barcodes</artifactId>

barcodes/src/main/java/com/itextpdf/barcodes/Barcode128.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV
@@ -44,15 +43,16 @@ This file is part of the iText (R) project.
4443
*/
4544
package com.itextpdf.barcodes;
4645

47-
import com.itextpdf.kernel.PdfException;
4846
import com.itextpdf.io.font.FontConstants;
4947
import com.itextpdf.io.font.PdfEncodings;
50-
import com.itextpdf.kernel.geom.Rectangle;
51-
import com.itextpdf.kernel.font.PdfFontFactory;
52-
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
48+
import com.itextpdf.kernel.PdfException;
5349
import com.itextpdf.kernel.color.Color;
50+
import com.itextpdf.kernel.font.PdfFontFactory;
51+
import com.itextpdf.kernel.geom.Rectangle;
5452
import com.itextpdf.kernel.pdf.PdfDocument;
53+
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
5554

55+
import java.io.IOException;
5656
import java.util.HashMap;
5757
import java.util.Map;
5858

@@ -237,8 +237,8 @@ public Barcode128(PdfDocument document) {
237237
barHeight = size * 3;
238238
textAlignment = ALIGN_CENTER;
239239
codeType = CODE128;
240-
} catch (Exception e) {
241-
throw new RuntimeException(e);
240+
} catch (IOException e) {
241+
throw new RuntimeException("Cannot create font", e);
242242
}
243243
}
244244

@@ -294,8 +294,8 @@ public static String getHumanReadableUCCEAN(String code) {
294294
for (int k = 2; k < 5; ++k) {
295295
if (code.length() < k)
296296
break;
297-
Integer subcode = Integer.parseInt(code.substring(0, k));
298-
n = ais.containsKey(subcode) ? ais.get(subcode) : 0;
297+
int subcode = Integer.parseInt(code.substring(0, k));
298+
n = ais.containsKey(subcode) ? (int)ais.get(subcode) : 0;
299299
if (n != 0) {
300300
idlen = k;
301301
break;
@@ -685,7 +685,7 @@ public void setCode(String code) {
685685
throw new IllegalArgumentException("AI is too short");
686686
}
687687
int ai = Integer.parseInt(sai);
688-
int len = ais.get(ai);
688+
int len = (int)ais.get(ai);
689689
if (len == 0) {
690690
throw new IllegalArgumentException("AI not found");
691691
}

barcodes/src/main/java/com/itextpdf/barcodes/Barcode1D.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/Barcode2D.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/Barcode39.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeCodabar.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV
@@ -55,7 +54,7 @@ This file is part of the iText (R) project.
5554

5655
public class BarcodeCodabar extends Barcode1D {
5756

58-
/**
57+
/**
5958
* The index chars to <CODE>BARS</CODE>.
6059
*/
6160
private static final String CHARS = "0123456789-$:/.+ABCD";
@@ -120,19 +119,19 @@ public static byte[] getBarsCodabar(String text) {
120119
text = text.toUpperCase();
121120
int len = text.length();
122121
if (len < 2) {
123-
throw new IllegalArgumentException(PdfException.CodabarMustHaveAtLeastAStartAndStopCharacter);
122+
throw new IllegalArgumentException(PdfException.CodabarMustHaveAtLeastStartAndStopCharacter);
124123
}
125124
if (CHARS.indexOf(text.charAt(0)) < START_STOP_IDX || CHARS.indexOf(text.charAt(len - 1)) < START_STOP_IDX) {
126125
throw new IllegalArgumentException(PdfException.CodabarMustHaveOneAbcdAsStartStopCharacter);
127126
}
128-
byte[] bars= new byte[text.length() * 8 - 1];
127+
byte[] bars = new byte[text.length() * 8 - 1];
129128
for (int k = 0; k < len; ++k) {
130129
int idx = CHARS.indexOf(text.charAt(k));
131130
if (idx >= START_STOP_IDX && k > 0 && k < len - 1) {
132-
throw new IllegalArgumentException(PdfException.CodabarStartStopCharacterAreOnlyExtremes);
131+
throw new IllegalArgumentException(PdfException.InCodabarStartStopCharactersAreOnlyAllowedAtTheExtremes);
133132
}
134133
if (idx < 0) {
135-
throw new IllegalArgumentException(PdfException.CodabarCharacterOneIsIllegal);
134+
throw new IllegalArgumentException(PdfException.IllegalCharacterInCodabarBarcode);
136135
}
137136
System.arraycopy(BARS[idx], 0, bars, k * 8, 7);
138137
}

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeEAN.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeEANSUPP.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeInter25.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/BarcodePDF417.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/BarcodePostnet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeQRCode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/dmcode/DmParams.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/dmcode/Placement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/dmcode/ReedSolomon.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/BitArray.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/BitMatrix.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/BitVector.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/BlockPair.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/ByteArray.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/ByteMatrix.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/CharacterSetECI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/EncodeHintType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV
@@ -61,6 +60,11 @@ public final class EncodeHintType {
6160
*/
6261
public static final EncodeHintType CHARACTER_SET = new EncodeHintType();
6362

63+
/**
64+
* Specifies the minimal version level to use, for example in QR Codes (type Integer).
65+
*/
66+
public static final EncodeHintType MIN_VERSION_NR = new EncodeHintType();
67+
6468
private EncodeHintType() {
6569
}
6670

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/Encoder.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV
@@ -104,7 +103,10 @@ public static void encode(String content, ErrorCorrectionLevel ecLevel, Map<Enco
104103
if (encoding == null) {
105104
encoding = DEFAULT_BYTE_MODE_ENCODING;
106105
}
107-
106+
int desiredMinVersion = (hints == null || hints.get(EncodeHintType.MIN_VERSION_NR) == null) ? 1 : (int) hints.get(EncodeHintType.MIN_VERSION_NR);
107+
//Check if desired level is within bounds of [1,40]
108+
if(desiredMinVersion<1)desiredMinVersion = 1;
109+
if(desiredMinVersion>40)desiredMinVersion = 40;
108110
// Step 1: Choose the mode (encoding).
109111
Mode mode = chooseMode(content, encoding);
110112

@@ -113,7 +115,7 @@ public static void encode(String content, ErrorCorrectionLevel ecLevel, Map<Enco
113115
appendBytes(content, mode, dataBits, encoding);
114116
// Step 3: Initialize QR code that can contain "dataBits".
115117
int numInputBytes = dataBits.sizeInBytes();
116-
initQRCode(numInputBytes, ecLevel, mode, qrCode);
118+
initQRCode(numInputBytes, ecLevel, desiredMinVersion, mode, qrCode);
117119

118120
// Step 4: Build another bit vector that contains header and data.
119121
BitVector headerAndDataBits = new BitVector();
@@ -240,13 +242,13 @@ private static int chooseMaskPattern(BitVector bits, ErrorCorrectionLevel ecLeve
240242
* Initialize "qrCode" according to "numInputBytes", "ecLevel", and "mode". On success,
241243
* modify "qrCode".
242244
*/
243-
private static void initQRCode(int numInputBytes, ErrorCorrectionLevel ecLevel, Mode mode,
245+
private static void initQRCode(int numInputBytes, ErrorCorrectionLevel ecLevel, int desiredMinVersion, Mode mode,
244246
QRCode qrCode) throws WriterException {
245247
qrCode.setECLevel(ecLevel);
246248
qrCode.setMode(mode);
247249

248250
// In the following comments, we use numbers of Version 7-H.
249-
for (int versionNum = 1; versionNum <= 40; versionNum++) {
251+
for (int versionNum = desiredMinVersion; versionNum <= 40; versionNum++) {
250252
Version version = Version.getVersionForNumber(versionNum);
251253
// numBytes = 196
252254
int numBytes = version.getTotalCodewords();

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/ErrorCorrectionLevel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/FormatInformation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/GF256.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/GF256Poly.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/MaskUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/MatrixUtil.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV
@@ -154,7 +153,7 @@ private MatrixUtil() {
154153
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
155154
// with the ByteMatrix initialized all to zero.
156155
public static void clearMatrix(ByteMatrix matrix) {
157-
matrix.clear((byte) -1);
156+
matrix.clear((byte) 0xff);
158157
}
159158

160159
// Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On
@@ -382,13 +381,13 @@ public static void makeVersionInfoBits(int version, BitVector bits) throws Write
382381
}
383382

384383
// Check if "value" is empty.
385-
private static boolean isEmpty(int value) {
386-
return value == -1;
384+
private static boolean isEmpty(byte value) {
385+
return value == (byte)0xff;
387386
}
388387

389388
// Check if "value" is valid.
390-
private static boolean isValidValue(int value) {
391-
return (value == -1 || // Empty.
389+
private static boolean isValidValue(byte value) {
390+
return (value == (byte)0xff || // Empty.
392391
value == 0 || // Light (white).
393392
value == 1); // Dark (black).
394393
}

barcodes/src/main/java/com/itextpdf/barcodes/qrcode/Mode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
$Id$
32
43
This file is part of the iText (R) project.
54
Copyright (c) 1998-2016 iText Group NV

0 commit comments

Comments
 (0)