Skip to content

Commit e7dc8b3

Browse files
committed
[RELEASE] iText 7 Core - 7.1.3
https://github.com/itext/itext7/releases/tag/7.1.3 * release/7.1.3: [RELEASE] 7.1.3-SNAPSHOT -> 7.1.3 Fix append mode for hybrid-reference documents Minor fixes in itextcore's documentation. Revert "Ignore memory hungry hyphen tests (layout) to be fixed in DEVSIX-2036" Add test for layout NonBreakingHyphenTest Ignore memory hungry hyphen tests (layout) to be fixed in DEVSIX-2036 Changed variable declaration and assignment to one line. Add test for DEVSIX-2033 DataMatrix. Add test with zero textSize DataMatrix: check negative textSize DataMatrix: check array bounds Wrap negative offsets in datamatrix Add an explicit type conversion in a view of c#-port. Avoid failing with exception in case form field /DA key is malformed Add multiline fields with justification test Add new tests for flattening of appearances with tricky dimensions Move tests for flattening of rotated fields to a separate class Scale flattened form fields appearance properly Add missing copyright headers Refactor a class used in a test to be static Add small content stream optimization for ActualTextIterator Fix a small bug in GlyphLine#equals Refactor variable name so it doesn't hide field Add meta info to the event counting API Fix processing the end of an inline image. Process rounded span's background. Add missing copyright headers Calculate border radii correctly. Fix dashed and dotted borders drawing algo. Update cmps. Make barcodes.dmcode.Placement thread safe Add DITO as supported product in document info comparison Add version info to document on creation Add missing copyright headers Fix backward compatibility issue in PdfFormField Use font from /DA for button Update PdfFormField#setDefaultAppearance() Add AppearanceResources and AppearanceXObject Add test for filling the form and updating it's font Remove unused file open in test. DEVSIX-2007 Ignore obviously suboptimal encodings for DataMatrix AUTO mode Add test. DEVSIX-2007 Add missing copyright headers Apply typography logic for every script in single text chunk separately Make OpenTypeFontTableReader tolerant to NULL offset in LookupList table Introduce TYPOGRAPHY_CONFIG property Add missing copyright headers Sign the document as pdfa if the source doucment is pdfa. Add a test. Add some new methods to handle signature's font color. Add a test. Add small fix for RetryRunner Add missing copyright headers Add event processing API Implement event based counting Process non-breaking hyphen. Refactor the list of symbols which should be considered on the layout level while hyphenating. Add some new tests. Add missing copyright headers Add unicode range logic to FontProvider Add test for PdfExplicitRemoteGoToDestination Fix inconsistency between containsKey and getAsArray Fix typo in javadoc Revert casts in ArrayUtil Rename ArrayUtil#toArray() to ArrayUtil#toIntArray() Changing annotations of JUnit tests Add missing copyright headers Add new tests for inline context blocks Fail typography loading if even simple static collection retrieval method doesn't work Add new test for block with big fixed height and keep-together property Refactor time-based system utils to better represent there purpose Add test for BarcodeDataMatrix Making Xmx param global to avoid SO issue DEVSIX-1979 Fix overflow renderer's height property processing. Add some new tests. Fix precision issue occured while image processing. Add a test. Add utility method for pdfHTML Svg integration Adding Xmx param to incrase heap size DEVSIX-1979 Insert value in PdfImageXObject dictionary map made from int array. DEVSIX-1974 Jacoco coverage to include all JUnit tests QA-349 Add missing copyright headers Add classes for correct creation of explicit destinations Add listAppender clearance before test run Adjust clipping border to include entire canvas for multi-line text. Remove @ignore, add template resource Fetch justifation of formfield from parent Fix typo in javadoc Revert multiple commits Add missed @category Add missed @category to ImageColorProfileTest and TableBorderTest Fix typo crude support of vertical alignment for inline-blocks add primitive support for table y-line-aligning for display:inline-table add temporary suppression on warning message Add a new hyphenation test. Fix case mismatch with .NET in woff2 tests Add a new test. Add missing copyright headers Add imagesWithDifferentDepth and add3dAnnotationTest Add missing copyright headers Add RetryOnFailure Fix off by one error. DEVSIX-1923 Fix bug in RunLengthDecodeFilter Avoid treating byte as a signed value for the sake of .NET porting Make changes to PR-25 Add tests for PR 25 fixed findFieldName method not giving the result more than one time. Add missing copyright headers Avoid exception in SignatureUtil when a read-only document was passed Specify message for the error logging in OtfClass class Consider word's prefix while splitting with hyphenation. Add some new tests. Revert "Add missing copyright headers" Fix copying of inherited page entries Add missing copyright headers Make checkbox field take into account user-specified font-size; auto-size font by default; fix bugs Add missing copyright headers Throw clear exception when facing an unsupported security hanlder [RELEASE] 7.1.2-SNAPSHOT -> 7.1.3-SNAPSHOT Add javadoc to Transform class Fix construction of Pdf3DAnnotations in PdfAnnotation#makeAnnotation Remove duplicate Barcode logic Add a new form field test. Fix offset issue. Consider word bounds while word splitting. Add new hyphenation tests. Revert "Revert "added non-breaking-space and non-breaking hyphen in TextRenderer#isGlyphPartOfWordForHyphenation"" Revert "added non-breaking-space and non-breaking hyphen in TextRenderer#isGlyphPartOfWordForHyphenation" added non-breaking-space and non-breaking hyphen in TextRenderer#isGlyphPartOfWordForHyphenation
2 parents 2f8edd2 + 9bb62b8 commit e7dc8b3

File tree

307 files changed

+8303
-1073
lines changed

Some content is hidden

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

307 files changed

+8303
-1073
lines changed

barcodes/pom.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
54
<parent>
65
<groupId>com.itextpdf</groupId>
76
<artifactId>root</artifactId>
8-
<version>7.1.2</version>
7+
<version>7.1.3</version>
98
</parent>
10-
119
<artifactId>barcodes</artifactId>
12-
1310
<name>iText 7 - barcodes</name>
1411
<url>http://itextpdf.com/</url>
15-
1612
<dependencies>
1713
<dependency>
1814
<groupId>com.itextpdf</groupId>
@@ -26,7 +22,6 @@
2622
<scope>test</scope>
2723
</dependency>
2824
</dependencies>
29-
3025
<build>
3126
<plugins>
3227
<plugin>

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

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ public PdfFormXObject createFormXObject(Color foreground, PdfDocument document)
218218
/**
219219
* Creates a PdfFormXObject with the barcode with given module width and module height.
220220
*
221-
* @param foreground The color of the pixels. It can be <CODE>null</CODE>
222-
* @param moduleSide The side (width and height) of the pixels.
223-
* @param document The document
221+
* @param foreground The color of the pixels. It can be <CODE>null</CODE>
222+
* @param moduleSide The side (width and height) of the pixels.
223+
* @param document The document
224224
* @return the XObject.
225225
*/
226226
public PdfFormXObject createFormXObject(Color foreground, float moduleSide, PdfDocument document) {
@@ -296,8 +296,8 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b
296296

297297
/**
298298
* Gets the barcode size
299-
* @param moduleHeight The height of the module
300-
* @param moduleWidth The width of the module
299+
* @param moduleHeight The height of the module
300+
* @param moduleWidth The width of the module
301301
* @return The size of the barcode
302302
*/
303303
public Rectangle getBarcodeSize(float moduleHeight, float moduleWidth) {
@@ -339,6 +339,12 @@ public int setCode(String text) {
339339
* <CODE>DM_ERROR_EXTENSION</CODE> - an error was while parsing an extension.
340340
*/
341341
public int setCode(byte[] text, int textOffset, int textSize) {
342+
if (textOffset < 0) {
343+
throw new IndexOutOfBoundsException("" + textOffset);
344+
}
345+
if (textOffset + textSize > text.length || textSize < 0) {
346+
throw new IndexOutOfBoundsException("" + textSize);
347+
}
342348
int extCount, e, k, full;
343349
DmParams dm, last;
344350
byte[] data = new byte[2500];
@@ -402,24 +408,25 @@ public int getHeight() {
402408
}
403409

404410
/**
405-
* Sets the height of the barcode. If the height is zero it will be calculated. This height doesn't include the whitespace border, if any.
411+
* Sets the height of the barcode. If the height is zero it will be calculated.
412+
* This height doesn't include the whitespace border, if any.
406413
*
407-
* The allowed dimensions are (height, width):<p>
414+
* The allowed dimensions are (width, height):<p>
408415
* 10, 10<br>
409416
* 12, 12<br>
410-
* 8, 18<br>
417+
* 18, 8<br>
411418
* 14, 14<br>
412-
* 8, 32<br>
419+
* 32, 8<br>
413420
* 16, 16<br>
414-
* 12, 26<br>
421+
* 26, 12<br>
415422
* 18, 18<br>
416423
* 20, 20<br>
417-
* 12, 36<br>
424+
* 36, 12<br>
418425
* 22, 22<br>
419-
* 16, 36<br>
426+
* 36, 16<br>
420427
* 24, 24<br>
421428
* 26, 26<br>
422-
* 16, 48<br>
429+
* 48, 16<br>
423430
* 32, 32<br>
424431
* 36, 36<br>
425432
* 40, 40<br>
@@ -453,24 +460,25 @@ public int getWidth() {
453460
}
454461

455462
/**
456-
* Sets the width of the barcode. If the width is zero it will be calculated. This width doesn't include the whitespace border, if any.
463+
* Sets the width of the barcode. If the width is zero it will be calculated.
464+
* This width doesn't include the whitespace border, if any.
457465
*
458-
* The allowed dimensions are (height, width):<p>
466+
* The allowed dimensions are (width, height):<p>
459467
* 10, 10<br>
460468
* 12, 12<br>
461-
* 8, 18<br>
469+
* 18, 8<br>
462470
* 14, 14<br>
463-
* 8, 32<br>
471+
* 32, 8<br>
464472
* 16, 16<br>
465-
* 12, 26<br>
473+
* 26, 12<br>
466474
* 18, 18<br>
467475
* 20, 20<br>
468-
* 12, 36<br>
476+
* 36, 12<br>
469477
* 22, 22<br>
470-
* 16, 36<br>
478+
* 36, 16<br>
471479
* 24, 24<br>
472480
* 26, 26<br>
473-
* 16, 48<br>
481+
* 48, 16<br>
474482
* 32, 32<br>
475483
* 36, 36<br>
476484
* 40, 40<br>
@@ -1072,7 +1080,7 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
10721080
if (j == 1)
10731081
dataOffsetNew = requiredCapacityForASCII;
10741082
}
1075-
addLatch = unlatch < 0 ? true : (dataOffset - requiredCapacityForASCII != unlatch);
1083+
addLatch = (unlatch < 0) || ((dataOffset - requiredCapacityForASCII) != unlatch);
10761084
if (requiredCapacityForC40orText % 3 == 0 &&
10771085
requiredCapacityForC40orText / 3 * 2 + (addLatch ? 2 : 0) < requiredCapacityForASCII) {
10781086
usingASCII = false;
@@ -1086,15 +1094,17 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
10861094
i--;
10871095
}
10881096
}
1089-
} else if (symbolIndex != -1)
1097+
} else if (symbolIndex != -1) {
10901098
usingASCII = true;
1091-
if (usingASCII)
1099+
}
1100+
if (dataOffset < 0) {
1101+
return -1;
1102+
}
1103+
if (usingASCII) {
10921104
return asciiEncodation(text, textOffset, 1, data, dataOffset, dataLength, prevEnc == mode ? 1 : -1, DM_ASCII, origDataOffset);
1105+
}
10931106
if (addLatch) {
1094-
if (c40)
1095-
data[dataOffset + ptrOut++] = LATCH_C40;
1096-
else
1097-
data[dataOffset + ptrOut++] = LATCH_TEXT;
1107+
data[dataOffset + ptrOut++] = c40 ? LATCH_C40 : LATCH_TEXT;
10981108
}
10991109
int[] enc = new int[textLength * 4 + 10];
11001110
encPtr = 0;
@@ -1197,7 +1207,7 @@ private void draw(byte[] data, int dataSize, DmParams dm) {
11971207
private static int minValueInColumn(int[][] array, int column) {
11981208
int min = Integer.MAX_VALUE;
11991209
for (int i = 0; i < 6; i++)
1200-
if (array[i][column] < min && array[i][column] >= 0)
1210+
if (array[i][column] < min && array[i][column] >= 0)
12011211
min = array[i][column];
12021212
return min != Integer.MAX_VALUE ? min : -1;
12031213
}
@@ -1246,29 +1256,28 @@ private int getEncodation(byte[] text, int textOffset, int textSize, byte[] data
12461256
f[3][0] = b256Encodation(text, textOffset, 1, dataDynamic[3], dataOffset, dataSize, 0, -1, dataOffset);
12471257
f[4][0] = X12Encodation(text, textOffset, 1, dataDynamic[4], dataOffset, dataSize, 0, -1, dataOffset);
12481258
f[5][0] = EdifactEncodation(text, textOffset, 1, dataDynamic[5], dataOffset, dataSize, 0, -1, dataOffset, sizeFixed);
1249-
int[] dataNewOffset = new int[6];
12501259
for (int i = 1; i < textSize; i++) {
12511260
int tempForMin[] = new int[6];
1252-
for (int k = 0; k < 6; k++) {
1253-
dataNewOffset[k] = f[k][i - 1] >= 0 ? f[k][i - 1] : Integer.MAX_VALUE;
1254-
}
12551261
for (int currEnc = 0; currEnc < 6; currEnc++) {
12561262
byte[][] dataDynamicInner = new byte[6][data.length];
12571263
for (int prevEnc = 0; prevEnc < 6; prevEnc++) {
12581264
System.arraycopy(dataDynamic[prevEnc], 0, dataDynamicInner[prevEnc], 0, data.length);
1259-
if (currEnc == 0)
1260-
tempForMin[prevEnc] = asciiEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset);
1261-
if (currEnc == 1)
1262-
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], true, i, prevEnc + 1, dataOffset);
1263-
if (currEnc == 2)
1264-
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], false, i, prevEnc + 1, dataOffset);
1265-
if (currEnc == 3)
1266-
tempForMin[prevEnc] = b256Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset);
1267-
if (currEnc == 4)
1268-
tempForMin[prevEnc] = X12Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset);
1269-
if (currEnc == 5)
1270-
tempForMin[prevEnc] = EdifactEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset, sizeFixed);
1271-
1265+
if (f[prevEnc][i - 1] < 0)
1266+
tempForMin[prevEnc] = -1;
1267+
else {
1268+
if (currEnc == 0)
1269+
tempForMin[prevEnc] = asciiEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset);
1270+
if (currEnc == 1)
1271+
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], true, i, prevEnc + 1, dataOffset);
1272+
if (currEnc == 2)
1273+
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], false, i, prevEnc + 1, dataOffset);
1274+
if (currEnc == 3)
1275+
tempForMin[prevEnc] = b256Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset);
1276+
if (currEnc == 4)
1277+
tempForMin[prevEnc] = X12Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset);
1278+
if (currEnc == 5)
1279+
tempForMin[prevEnc] = EdifactEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset, sizeFixed);
1280+
}
12721281
}
12731282
solveFAndSwitchMode(tempForMin, currEnc, i);
12741283
if (switchMode[currEnc][i] != 0)
@@ -1384,10 +1393,10 @@ else if (eci < 16383) {
13841393
if (ptrIn + 1 > textSize)
13851394
return -1;
13861395
c = text[textOffset + ptrIn++] & 0xff;
1387-
if (c != '5' && c != '5')
1396+
if (c != '5')
13881397
return -1;
13891398
data[ptrOut++] = (byte) 234;
1390-
data[ptrOut++] = (byte) (c == '5' ? 236 : 237);
1399+
data[ptrOut++] = (byte) 236;
13911400
break;
13921401
case 'f':
13931402
if (order != 1 && (order != 2 || text[textOffset] != 's' && text[textOffset] != 'm'))
@@ -1397,5 +1406,4 @@ else if (eci < 16383) {
13971406
}
13981407
return -1;
13991408
}
1400-
14011409
}

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,25 @@ This file is part of the iText (R) project.
4444
package com.itextpdf.barcodes.dmcode;
4545

4646
import java.util.Arrays;
47-
import java.util.HashMap;
4847
import java.util.Map;
48+
import java.util.concurrent.ConcurrentHashMap;
4949

5050
public class Placement {
51-
private int nrow;
52-
private int ncol;
53-
private short[] array;
54-
private static final Map<Integer, short[]> cache = new HashMap<>();
55-
56-
private Placement() {
51+
private final int nrow;
52+
private final int ncol;
53+
private final short[] array;
54+
private static final Map<Integer, short[]> cache = new ConcurrentHashMap<>();
55+
56+
private Placement(int nrow, int ncol) {
57+
this.nrow = nrow;
58+
this.ncol = ncol;
59+
array = new short[nrow * ncol];
5760
}
5861

5962

6063
/**
6164
* Execute the placement
65+
*
6266
* @param nrow number of rows
6367
* @param ncol number of columns
6468
* @return array containing appropriate values for ECC200
@@ -68,10 +72,7 @@ public static short[] doPlacement(int nrow, int ncol) {
6872
short[] pc = cache.get(key);
6973
if (pc != null)
7074
return pc;
71-
Placement p = new Placement();
72-
p.nrow = nrow;
73-
p.ncol = ncol;
74-
p.array = new short[nrow * ncol];
75+
Placement p = new Placement(nrow, ncol);
7576
p.ecc200();
7677
cache.put(key, p.array);
7778
return p.array;
@@ -150,19 +151,19 @@ private void corner4(int chr) {
150151
/* "ECC200" fills an nrow x ncol array with appropriate values for ECC200 */
151152
private void ecc200() {
152153
int row, col, chr;
153-
/* First, fill the array[] with invalid entries */
154+
/* First, fill the array[] with invalid entries */
154155
Arrays.fill(array, (short) 0);
155-
/* Starting in the correct location for character #1, bit 8,... */
156+
/* Starting in the correct location for character #1, bit 8,... */
156157
chr = 1;
157158
row = 4;
158159
col = 0;
159160
do {
160-
/* repeatedly first check for one of the special corner cases, then... */
161+
/* repeatedly first check for one of the special corner cases, then... */
161162
if (row == nrow && col == 0) corner1(chr++);
162163
if (row == nrow - 2 && col == 0 && ncol % 4 != 0) corner2(chr++);
163164
if (row == nrow - 2 && col == 0 && ncol % 8 == 4) corner3(chr++);
164165
if (row == nrow + 4 && col == 2 && ncol % 8 == 0) corner4(chr++);
165-
/* sweep upward diagonally, inserting successive characters,... */
166+
/* sweep upward diagonally, inserting successive characters,... */
166167
do {
167168
if (row < nrow && col >= 0 && array[row * ncol + col] == 0)
168169
utah(row, col, chr++);
@@ -171,7 +172,7 @@ private void ecc200() {
171172
} while (row >= 0 && col < ncol);
172173
row += 1;
173174
col += 3;
174-
/* & then sweep downward diagonally, inserting successive characters,... */
175+
/* & then sweep downward diagonally, inserting successive characters,... */
175176

176177
do {
177178
if (row >= 0 && col < ncol && array[row * ncol + col] == 0)
@@ -181,9 +182,9 @@ private void ecc200() {
181182
} while (row < nrow && col >= 0);
182183
row += 3;
183184
col += 1;
184-
/* ... until the entire array is scanned */
185+
/* ... until the entire array is scanned */
185186
} while (row < nrow || col < ncol);
186-
/* Lastly, if the lower righthand corner is untouched, fill in fixed pattern */
187+
/* Lastly, if the lower righthand corner is untouched, fill in fixed pattern */
187188
if (array[nrow * ncol - 1] == 0) {
188189
array[nrow * ncol - 1] = array[nrow * ncol - ncol - 2] = 1;
189190
}

0 commit comments

Comments
 (0)