Skip to content

Commit

Permalink
[RELEASE] iText 7 Core - 7.1.3
Browse files Browse the repository at this point in the history
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
  • Loading branch information
iText-CI committed Jul 27, 2018
2 parents 2f8edd2 + 9bb62b8 commit e7dc8b3
Show file tree
Hide file tree
Showing 307 changed files with 8,303 additions and 1,073 deletions.
7 changes: 1 addition & 6 deletions barcodes/pom.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.1.2</version>
<version>7.1.3</version>
</parent>

<artifactId>barcodes</artifactId>

<name>iText 7 - barcodes</name>
<url>http://itextpdf.com/</url>

<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
Expand All @@ -26,7 +22,6 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
106 changes: 57 additions & 49 deletions barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ public PdfFormXObject createFormXObject(Color foreground, PdfDocument document)
/**
* Creates a PdfFormXObject with the barcode with given module width and module height.
*
* @param foreground The color of the pixels. It can be <CODE>null</CODE>
* @param moduleSide The side (width and height) of the pixels.
* @param document The document
* @param foreground The color of the pixels. It can be <CODE>null</CODE>
* @param moduleSide The side (width and height) of the pixels.
* @param document The document
* @return the XObject.
*/
public PdfFormXObject createFormXObject(Color foreground, float moduleSide, PdfDocument document) {
Expand Down Expand Up @@ -296,8 +296,8 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b

/**
* Gets the barcode size
* @param moduleHeight The height of the module
* @param moduleWidth The width of the module
* @param moduleHeight The height of the module
* @param moduleWidth The width of the module
* @return The size of the barcode
*/
public Rectangle getBarcodeSize(float moduleHeight, float moduleWidth) {
Expand Down Expand Up @@ -339,6 +339,12 @@ public int setCode(String text) {
* <CODE>DM_ERROR_EXTENSION</CODE> - an error was while parsing an extension.
*/
public int setCode(byte[] text, int textOffset, int textSize) {
if (textOffset < 0) {
throw new IndexOutOfBoundsException("" + textOffset);
}
if (textOffset + textSize > text.length || textSize < 0) {
throw new IndexOutOfBoundsException("" + textSize);
}
int extCount, e, k, full;
DmParams dm, last;
byte[] data = new byte[2500];
Expand Down Expand Up @@ -402,24 +408,25 @@ public int getHeight() {
}

/**
* 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.
* 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.
*
* The allowed dimensions are (height, width):<p>
* The allowed dimensions are (width, height):<p>
* 10, 10<br>
* 12, 12<br>
* 8, 18<br>
* 18, 8<br>
* 14, 14<br>
* 8, 32<br>
* 32, 8<br>
* 16, 16<br>
* 12, 26<br>
* 26, 12<br>
* 18, 18<br>
* 20, 20<br>
* 12, 36<br>
* 36, 12<br>
* 22, 22<br>
* 16, 36<br>
* 36, 16<br>
* 24, 24<br>
* 26, 26<br>
* 16, 48<br>
* 48, 16<br>
* 32, 32<br>
* 36, 36<br>
* 40, 40<br>
Expand Down Expand Up @@ -453,24 +460,25 @@ public int getWidth() {
}

/**
* 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.
* 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.
*
* The allowed dimensions are (height, width):<p>
* The allowed dimensions are (width, height):<p>
* 10, 10<br>
* 12, 12<br>
* 8, 18<br>
* 18, 8<br>
* 14, 14<br>
* 8, 32<br>
* 32, 8<br>
* 16, 16<br>
* 12, 26<br>
* 26, 12<br>
* 18, 18<br>
* 20, 20<br>
* 12, 36<br>
* 36, 12<br>
* 22, 22<br>
* 16, 36<br>
* 36, 16<br>
* 24, 24<br>
* 26, 26<br>
* 16, 48<br>
* 48, 16<br>
* 32, 32<br>
* 36, 36<br>
* 40, 40<br>
Expand Down Expand Up @@ -1072,7 +1080,7 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
if (j == 1)
dataOffsetNew = requiredCapacityForASCII;
}
addLatch = unlatch < 0 ? true : (dataOffset - requiredCapacityForASCII != unlatch);
addLatch = (unlatch < 0) || ((dataOffset - requiredCapacityForASCII) != unlatch);
if (requiredCapacityForC40orText % 3 == 0 &&
requiredCapacityForC40orText / 3 * 2 + (addLatch ? 2 : 0) < requiredCapacityForASCII) {
usingASCII = false;
Expand All @@ -1086,15 +1094,17 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
i--;
}
}
} else if (symbolIndex != -1)
} else if (symbolIndex != -1) {
usingASCII = true;
if (usingASCII)
}
if (dataOffset < 0) {
return -1;
}
if (usingASCII) {
return asciiEncodation(text, textOffset, 1, data, dataOffset, dataLength, prevEnc == mode ? 1 : -1, DM_ASCII, origDataOffset);
}
if (addLatch) {
if (c40)
data[dataOffset + ptrOut++] = LATCH_C40;
else
data[dataOffset + ptrOut++] = LATCH_TEXT;
data[dataOffset + ptrOut++] = c40 ? LATCH_C40 : LATCH_TEXT;
}
int[] enc = new int[textLength * 4 + 10];
encPtr = 0;
Expand Down Expand Up @@ -1197,7 +1207,7 @@ private void draw(byte[] data, int dataSize, DmParams dm) {
private static int minValueInColumn(int[][] array, int column) {
int min = Integer.MAX_VALUE;
for (int i = 0; i < 6; i++)
if (array[i][column] < min && array[i][column] >= 0)
if (array[i][column] < min && array[i][column] >= 0)
min = array[i][column];
return min != Integer.MAX_VALUE ? min : -1;
}
Expand Down Expand Up @@ -1246,29 +1256,28 @@ private int getEncodation(byte[] text, int textOffset, int textSize, byte[] data
f[3][0] = b256Encodation(text, textOffset, 1, dataDynamic[3], dataOffset, dataSize, 0, -1, dataOffset);
f[4][0] = X12Encodation(text, textOffset, 1, dataDynamic[4], dataOffset, dataSize, 0, -1, dataOffset);
f[5][0] = EdifactEncodation(text, textOffset, 1, dataDynamic[5], dataOffset, dataSize, 0, -1, dataOffset, sizeFixed);
int[] dataNewOffset = new int[6];
for (int i = 1; i < textSize; i++) {
int tempForMin[] = new int[6];
for (int k = 0; k < 6; k++) {
dataNewOffset[k] = f[k][i - 1] >= 0 ? f[k][i - 1] : Integer.MAX_VALUE;
}
for (int currEnc = 0; currEnc < 6; currEnc++) {
byte[][] dataDynamicInner = new byte[6][data.length];
for (int prevEnc = 0; prevEnc < 6; prevEnc++) {
System.arraycopy(dataDynamic[prevEnc], 0, dataDynamicInner[prevEnc], 0, data.length);
if (currEnc == 0)
tempForMin[prevEnc] = asciiEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset);
if (currEnc == 1)
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], true, i, prevEnc + 1, dataOffset);
if (currEnc == 2)
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], false, i, prevEnc + 1, dataOffset);
if (currEnc == 3)
tempForMin[prevEnc] = b256Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset);
if (currEnc == 4)
tempForMin[prevEnc] = X12Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset);
if (currEnc == 5)
tempForMin[prevEnc] = EdifactEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], dataNewOffset[prevEnc] + dataOffset, dataSize - dataNewOffset[prevEnc], i, prevEnc + 1, dataOffset, sizeFixed);

if (f[prevEnc][i - 1] < 0)
tempForMin[prevEnc] = -1;
else {
if (currEnc == 0)
tempForMin[prevEnc] = asciiEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset);
if (currEnc == 1)
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], true, i, prevEnc + 1, dataOffset);
if (currEnc == 2)
tempForMin[prevEnc] = C40OrTextEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], false, i, prevEnc + 1, dataOffset);
if (currEnc == 3)
tempForMin[prevEnc] = b256Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset);
if (currEnc == 4)
tempForMin[prevEnc] = X12Encodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset);
if (currEnc == 5)
tempForMin[prevEnc] = EdifactEncodation(text, textOffset + i, 1, dataDynamicInner[prevEnc], f[prevEnc][i - 1] + dataOffset, dataSize - f[prevEnc][i - 1], i, prevEnc + 1, dataOffset, sizeFixed);
}
}
solveFAndSwitchMode(tempForMin, currEnc, i);
if (switchMode[currEnc][i] != 0)
Expand Down Expand Up @@ -1384,10 +1393,10 @@ else if (eci < 16383) {
if (ptrIn + 1 > textSize)
return -1;
c = text[textOffset + ptrIn++] & 0xff;
if (c != '5' && c != '5')
if (c != '5')
return -1;
data[ptrOut++] = (byte) 234;
data[ptrOut++] = (byte) (c == '5' ? 236 : 237);
data[ptrOut++] = (byte) 236;
break;
case 'f':
if (order != 1 && (order != 2 || text[textOffset] != 's' && text[textOffset] != 'm'))
Expand All @@ -1397,5 +1406,4 @@ else if (eci < 16383) {
}
return -1;
}

}
37 changes: 19 additions & 18 deletions barcodes/src/main/java/com/itextpdf/barcodes/dmcode/Placement.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ This file is part of the iText (R) project.
package com.itextpdf.barcodes.dmcode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Placement {
private int nrow;
private int ncol;
private short[] array;
private static final Map<Integer, short[]> cache = new HashMap<>();

private Placement() {
private final int nrow;
private final int ncol;
private final short[] array;
private static final Map<Integer, short[]> cache = new ConcurrentHashMap<>();

private Placement(int nrow, int ncol) {
this.nrow = nrow;
this.ncol = ncol;
array = new short[nrow * ncol];
}


/**
* Execute the placement
*
* @param nrow number of rows
* @param ncol number of columns
* @return array containing appropriate values for ECC200
Expand All @@ -68,10 +72,7 @@ public static short[] doPlacement(int nrow, int ncol) {
short[] pc = cache.get(key);
if (pc != null)
return pc;
Placement p = new Placement();
p.nrow = nrow;
p.ncol = ncol;
p.array = new short[nrow * ncol];
Placement p = new Placement(nrow, ncol);
p.ecc200();
cache.put(key, p.array);
return p.array;
Expand Down Expand Up @@ -150,19 +151,19 @@ private void corner4(int chr) {
/* "ECC200" fills an nrow x ncol array with appropriate values for ECC200 */
private void ecc200() {
int row, col, chr;
/* First, fill the array[] with invalid entries */
/* First, fill the array[] with invalid entries */
Arrays.fill(array, (short) 0);
/* Starting in the correct location for character #1, bit 8,... */
/* Starting in the correct location for character #1, bit 8,... */
chr = 1;
row = 4;
col = 0;
do {
/* repeatedly first check for one of the special corner cases, then... */
/* repeatedly first check for one of the special corner cases, then... */
if (row == nrow && col == 0) corner1(chr++);
if (row == nrow - 2 && col == 0 && ncol % 4 != 0) corner2(chr++);
if (row == nrow - 2 && col == 0 && ncol % 8 == 4) corner3(chr++);
if (row == nrow + 4 && col == 2 && ncol % 8 == 0) corner4(chr++);
/* sweep upward diagonally, inserting successive characters,... */
/* sweep upward diagonally, inserting successive characters,... */
do {
if (row < nrow && col >= 0 && array[row * ncol + col] == 0)
utah(row, col, chr++);
Expand All @@ -171,7 +172,7 @@ private void ecc200() {
} while (row >= 0 && col < ncol);
row += 1;
col += 3;
/* & then sweep downward diagonally, inserting successive characters,... */
/* & then sweep downward diagonally, inserting successive characters,... */

do {
if (row >= 0 && col < ncol && array[row * ncol + col] == 0)
Expand All @@ -181,9 +182,9 @@ private void ecc200() {
} while (row < nrow && col >= 0);
row += 3;
col += 1;
/* ... until the entire array is scanned */
/* ... until the entire array is scanned */
} while (row < nrow || col < ncol);
/* Lastly, if the lower righthand corner is untouched, fill in fixed pattern */
/* Lastly, if the lower righthand corner is untouched, fill in fixed pattern */
if (array[nrow * ncol - 1] == 0) {
array[nrow * ncol - 1] = array[nrow * ncol - ncol - 2] = 1;
}
Expand Down
Loading

0 comments on commit e7dc8b3

Please sign in to comment.