Skip to content

Commit c4daee4

Browse files
committed
Merge branch 'release_branch_DEVSIX-5576' into master-rc
2 parents 87fffa6 + 9c5e0c3 commit c4daee4

File tree

1,672 files changed

+42462
-35472
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,672 files changed

+42462
-35472
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The iText 7 Core/Community release contains:
1414
- ```sign-x.y.z.jar```: use this if you need support for digital signatures
1515
- ```styled-xml-parser-x.y.z.jar```: use this if you need support for SVG or html2pdf
1616
- ```svg-x.y.z.jar```: SVG support
17+
- ```commons-x.y.z.jar```: commons module
1718

1819
The **iText 7 Community** source code is hosted on [Github][github], where you can also [download the latest releases][latest].
1920

barcodes/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.16</version>
7+
<version>7.2.0</version>
88
</parent>
99
<artifactId>barcodes</artifactId>
1010
<name>iText 7 - barcodes</name>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.barcodes;
4545

46-
import com.itextpdf.kernel.PdfException;
46+
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
47+
import com.itextpdf.kernel.exceptions.PdfException;
4748
import com.itextpdf.kernel.colors.Color;
4849
import com.itextpdf.kernel.font.PdfFont;
4950
import com.itextpdf.kernel.geom.Rectangle;
@@ -352,7 +353,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
352353
for (int k = 0; k < tLen; ++k) {
353354
c = text.charAt(k);
354355
if (c > 127 && c != FNC1)
355-
throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1);
356+
throw new PdfException(BarcodeExceptionMessageConstant.THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128);
356357
}
357358
c = text.charAt(0);
358359
char currentCode = getStartSymbol(codeSet);
@@ -383,7 +384,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
383384
++index;
384385
}
385386
if (codeSet != Barcode128CodeSet.AUTO && currentCode != getStartSymbol(codeSet))
386-
throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1);
387+
throw new PdfException(BarcodeExceptionMessageConstant.THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128);
387388
while (index < tLen) {
388389
switch (currentCode) {
389390
case START_A: {
@@ -452,7 +453,7 @@ else if (c < ' ') {
452453
break;
453454
}
454455
if (codeSet != Barcode128CodeSet.AUTO && currentCode != getStartSymbol(codeSet))
455-
throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1);
456+
throw new PdfException(BarcodeExceptionMessageConstant.THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128);
456457
}
457458
return out;
458459
}

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.barcodes;
4545

46-
import com.itextpdf.kernel.PdfException;
46+
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
4747
import com.itextpdf.kernel.font.PdfFont;
4848
import com.itextpdf.kernel.geom.Rectangle;
4949
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
@@ -167,19 +167,23 @@ public static byte[] getBarsCodabar(String text) {
167167
text = text.toUpperCase();
168168
int len = text.length();
169169
if (len < 2) {
170-
throw new IllegalArgumentException(PdfException.CodabarMustHaveAtLeastStartAndStopCharacter);
170+
throw new IllegalArgumentException(
171+
BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER);
171172
}
172173
if (CHARS.indexOf(text.charAt(0)) < START_STOP_IDX || CHARS.indexOf(text.charAt(len - 1)) < START_STOP_IDX) {
173-
throw new IllegalArgumentException(PdfException.CodabarMustHaveOneAbcdAsStartStopCharacter);
174+
throw new IllegalArgumentException(
175+
BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER);
174176
}
175177
byte[] bars = new byte[text.length() * 8 - 1];
176178
for (int k = 0; k < len; ++k) {
177179
int idx = CHARS.indexOf(text.charAt(k));
178180
if (idx >= START_STOP_IDX && k > 0 && k < len - 1) {
179-
throw new IllegalArgumentException(PdfException.InCodabarStartStopCharactersAreOnlyAllowedAtTheExtremes);
181+
throw new IllegalArgumentException(BarcodeExceptionMessageConstant.
182+
IN_CODABAR_START_STOP_CHARACTERS_ARE_ONLY_ALLOWED_AT_THE_EXTREMES);
180183
}
181184
if (idx < 0) {
182-
throw new IllegalArgumentException(PdfException.IllegalCharacterInCodabarBarcode);
185+
throw new IllegalArgumentException(
186+
BarcodeExceptionMessageConstant.ILLEGAL_CHARACTER_IN_CODABAR_BARCODE);
183187
}
184188
System.arraycopy(BARS[idx], 0, bars, k * 8, 7);
185189
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.barcodes;
4545

46-
import com.itextpdf.kernel.PdfException;
46+
import com.itextpdf.kernel.exceptions.PdfException;
4747
import com.itextpdf.kernel.font.PdfFont;
4848
import com.itextpdf.kernel.geom.Rectangle;
4949
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.barcodes;
4545

46-
47-
import com.itextpdf.kernel.PdfException;
46+
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
4847
import com.itextpdf.io.font.FontProgram;
4948
import com.itextpdf.kernel.geom.Rectangle;
5049
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
@@ -159,6 +158,6 @@ public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
159158
*/
160159
@Override
161160
public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
162-
throw new UnsupportedOperationException(PdfException.TwoBarcodeMustBeExternally);
161+
throw new UnsupportedOperationException(BarcodeExceptionMessageConstant.TWO_BARCODE_MUST_BE_EXTERNALLY);
163162
}
164163
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.barcodes;
4545

46-
47-
import com.itextpdf.kernel.PdfException;
46+
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
47+
import com.itextpdf.kernel.exceptions.PdfException;
4848
import com.itextpdf.kernel.font.PdfFont;
4949
import com.itextpdf.kernel.geom.Rectangle;
5050
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
@@ -163,7 +163,7 @@ public static char getChecksum(String text) {
163163
public static byte[] getBarsInter25(String text) {
164164
text = keepNumbers(text);
165165
if ((text.length() & 1) != 0) {
166-
throw new PdfException(PdfException.TextMustBeEven);
166+
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_MUST_BE_EVEN);
167167
}
168168
byte[] bars = new byte[text.length() * 5 + 7];
169169
int pb = 0;

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.barcodes;
4545

46-
import com.itextpdf.kernel.PdfException;
46+
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
47+
import com.itextpdf.kernel.exceptions.PdfException;
4748
import com.itextpdf.io.font.PdfEncodings;
4849
import com.itextpdf.kernel.geom.Rectangle;
4950
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
@@ -726,13 +727,13 @@ public void paintCode() {
726727
int maxErr, lenErr, tot, pad;
727728
if ((options & PDF417_USE_RAW_CODEWORDS) != 0) {
728729
if (lenCodewords > MAX_DATA_CODEWORDS || lenCodewords < 1 || lenCodewords != codewords[0]) {
729-
throw new PdfException(PdfException.InvalidCodewordSize);
730+
throw new PdfException(BarcodeExceptionMessageConstant.INVALID_CODEWORD_SIZE);
730731
}
731732
} else {
732733
if (code == null)
733-
throw new PdfException(PdfException.TextCannotBeNull);
734+
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_CANNOT_BE_NULL);
734735
if (code.length > ABSOLUTE_MAX_TEXT_SIZE) {
735-
throw new PdfException(PdfException.TextIsTooBig);
736+
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
736737
}
737738
segmentList = new SegmentList();
738739
breakString();
@@ -1316,7 +1317,7 @@ void byteCompaction(int start, int length) {
13161317
int k, j;
13171318
int size = length / 6 * 5 + length % 6;
13181319
if (size + cwPtr > MAX_DATA_CODEWORDS) {
1319-
throw new PdfException(PdfException.TextIsTooBig);
1320+
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
13201321
}
13211322
length += start;
13221323
for (k = start; k < length; k += 6) {
@@ -1501,7 +1502,7 @@ private void numberCompaction(byte[] input, int start, int length) {
15011502
else
15021503
size = full + size / 3 + 1;
15031504
if (size + cwPtr > MAX_DATA_CODEWORDS) {
1504-
throw new PdfException(PdfException.TextIsTooBig);
1505+
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
15051506
}
15061507
length += start;
15071508
for (k = start; k < length; k += 44) {
@@ -1512,13 +1513,13 @@ private void numberCompaction(byte[] input, int start, int length) {
15121513

15131514
private void macroCodes() {
15141515
if (macroSegmentId < 0) {
1515-
throw new PdfException(PdfException.MacroSegmentIdMustBeGtOrEqZero);
1516+
throw new PdfException(BarcodeExceptionMessageConstant.MACRO_SEGMENT_ID_MUST_BE_GT_OR_EQ_ZERO);
15161517
}
15171518
if (macroSegmentId >= macroSegmentCount) {
1518-
throw new PdfException(PdfException.MacroSegmentIdMustBeLtMacroSegmentCount);
1519+
throw new PdfException(BarcodeExceptionMessageConstant.MACRO_SEGMENT_ID_MUST_BE_LT_MACRO_SEGMENT_COUNT);
15191520
}
15201521
if (macroSegmentCount < 1) {
1521-
throw new PdfException(PdfException.MacroSegmentIdMustBeGtZero);
1522+
throw new PdfException(BarcodeExceptionMessageConstant.MACRO_SEGMENT_ID_MUST_BE_GT_ZERO);
15221523
}
15231524

15241525
macroIndex = cwPtr;
@@ -1671,7 +1672,7 @@ private void textCompaction(byte[] input, int start, int length) {
16711672
dest[ptr++] = PS;
16721673
size = (ptr + fullBytes) / 2;
16731674
if (size + cwPtr > MAX_DATA_CODEWORDS) {
1674-
throw new PdfException(PdfException.TextIsTooBig);
1675+
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
16751676
}
16761677
length = ptr;
16771678
ptr = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ This file is part of the iText (R) project.
4646
import com.itextpdf.barcodes.qrcode.ByteMatrix;
4747
import com.itextpdf.barcodes.qrcode.EncodeHintType;
4848
import com.itextpdf.barcodes.qrcode.QRCodeWriter;
49-
import com.itextpdf.barcodes.qrcode.WriterException;
49+
import com.itextpdf.barcodes.exceptions.WriterException;
5050
import com.itextpdf.kernel.geom.Rectangle;
5151
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
5252
import com.itextpdf.kernel.colors.Color;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 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+
package com.itextpdf.barcodes.exceptions;
24+
25+
/**
26+
* Class that bundles all the error message templates as constants.
27+
*/
28+
public final class BarcodeExceptionMessageConstant {
29+
public static final String CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER = "Codabar must have at least start "
30+
+ "and stop character.";
31+
public static final String CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER = "Codabar must have one of 'ABCD' "
32+
+ "as start/stop character.";
33+
public static final String ILLEGAL_CHARACTER_IN_CODABAR_BARCODE = "Illegal character in Codabar Barcode.";
34+
public static final String IN_CODABAR_START_STOP_CHARACTERS_ARE_ONLY_ALLOWED_AT_THE_EXTREMES = "In Codabar, "
35+
+ "start/stop characters are only allowed at the extremes.";
36+
public static final String INVALID_CODEWORD_SIZE = "Invalid codeword size.";
37+
public static final String MACRO_SEGMENT_ID_MUST_BE_GT_OR_EQ_ZERO = "macroSegmentId must be >= 0";
38+
public static final String MACRO_SEGMENT_ID_MUST_BE_GT_ZERO = "macroSegmentId must be > 0";
39+
public static final String MACRO_SEGMENT_ID_MUST_BE_LT_MACRO_SEGMENT_COUNT = "macroSegmentId "
40+
+ "must be < macroSemgentCount";
41+
public static final String TEXT_CANNOT_BE_NULL = "Text cannot be null.";
42+
public static final String TEXT_IS_TOO_BIG = "Text is too big.";
43+
public static final String TEXT_MUST_BE_EVEN = "The text length must be even.";
44+
public static final String TWO_BARCODE_MUST_BE_EXTERNALLY = "The two barcodes must be composed externally.";
45+
public static final String THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128 = "There are illegal characters for "
46+
+ "barcode 128 in {0}.";
47+
48+
private BarcodeExceptionMessageConstant(){}
49+
}

0 commit comments

Comments
 (0)