Skip to content

Commit eed0ef2

Browse files
committed
Merge branch 'release/7.0.0-RC.20160321'
2 parents 67fd429 + 397e851 commit eed0ef2

File tree

528 files changed

+19803
-14444
lines changed

Some content is hidden

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

528 files changed

+19803
-14444
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,6 @@ nbactions*.xml
151151
.pmdruleset.xml
152152

153153
# Ignore generated files
154-
samples/src/test/resources/db/filmfestival.log
154+
filmfestival.log
155155

156156
.vagrant/

BUILDING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
To build iText 7, [Maven][1] must be installed.
2+
3+
Running install without a profile will generate the iText 7 jars:
4+
```bash
5+
$ mvn clean install -Dmaven.test.skip=true | tee mvn.log
6+
```
7+
8+
To run the tests, [Ghostscript][2] and [Imagemagick][3] must be installed.
9+
```bash
10+
$ mvn clean install -Dmaven.test.failure.ignore=false -DgsExec=$(which gs) -DcompareExec=$(which compare) | tee mvn.log
11+
```
12+
13+
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.
14+
```bash
15+
$ vagrant box add ubuntu/trusty64
16+
$ vagrant up
17+
$ vagrant ssh -- 'cd /vagrant ; mvn clean install -Dmaven.test.skip=true' | tee mvn.log
18+
```
19+
20+
[1]: http://maven.apache.org/
21+
[2]: http://www.ghostscript.com/
22+
[3]: http://www.imagemagick.org/
23+
[4]: https://www.vagrantup.com/
24+
[5]: http://www.ubuntu.com/
25+
[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-RC.20160201</version>
8+
<version>7.0.0-RC.20160321</version>
99
</parent>
1010

1111
<artifactId>barcodes</artifactId>

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

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public class BarcodeDataMatrix extends Barcode2D {
7575
*/
7676
public static final int DM_TEST = 64;
7777

78+
public static final String DEFAULT_DATA_MATRIX_ENCODING = "iso-8859-1";
79+
80+
private String encoding;
81+
7882
private final static DmParams[] dmSizes = {
7983
new DmParams(10, 10, 10, 10, 3, 3, 5),
8084
new DmParams(12, 12, 12, 12, 5, 5, 7),
@@ -120,6 +124,17 @@ public class BarcodeDataMatrix extends Barcode2D {
120124
* Creates an instance of this class.
121125
*/
122126
public BarcodeDataMatrix() {
127+
encoding = DEFAULT_DATA_MATRIX_ENCODING;
128+
}
129+
130+
public BarcodeDataMatrix(String code) {
131+
encoding = DEFAULT_DATA_MATRIX_ENCODING;
132+
setCode(code);
133+
}
134+
135+
public BarcodeDataMatrix(String code, String encoding) {
136+
this.encoding = encoding;
137+
setCode(code);
123138
}
124139

125140
@Override
@@ -140,8 +155,8 @@ public PdfFormXObject createFormXObject(Color foreground, PdfDocument document)
140155
/**
141156
* Creates a PdfFormXObject with the barcode with given module width and module height.
142157
*
143-
* @param foreground the color of the pixels. It can be <CODE>null</CODE>
144-
* @param moduleSide the side (width and height) of the pixels.
158+
* @param foreground the color of the pixels. It can be <CODE>null</CODE>
159+
* @param moduleSide the side (width and height) of the pixels.
145160
* @return the XObject.
146161
*/
147162
public PdfFormXObject createFormXObject(Color foreground, float moduleSide, PdfDocument document) {
@@ -236,7 +251,7 @@ public Rectangle getBarcodeSize(float moduleHeight, float moduleWidth) {
236251
public int setCode(String text) {
237252
byte[] t;
238253
try {
239-
t = text.getBytes("iso-8859-1");
254+
t = text.getBytes(encoding);
240255
} catch (UnsupportedEncodingException exc) {
241256
throw new IllegalArgumentException("text has to be encoded in iso-8859-1");
242257
}
@@ -436,6 +451,8 @@ public int getOptions() {
436451
return options;
437452
}
438453

454+
455+
439456
/**
440457
* Sets the options for the barcode generation. The options can be:<p>
441458
* One of:<br>
@@ -468,6 +485,19 @@ public void setOptions(int options) {
468485
this.options = options;
469486
}
470487

488+
/**
489+
* setting encoding for data matrix code ( default encoding iso-8859-1)
490+
* @param encoding encoding for data matrix code
491+
*/
492+
public void setEncoding(String encoding) {
493+
this.encoding = encoding;
494+
}
495+
496+
public String getEncoding() {
497+
return encoding;
498+
}
499+
500+
471501

472502
private static void makePadding(byte[] data, int position, int count) {
473503
//already in ascii mode

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.itextpdf.barcodes;
22

33

4+
import com.itextpdf.barcodes.qrcode.EncodeHintType;
45
import com.itextpdf.kernel.PdfException;
56
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
67
import com.itextpdf.kernel.color.Color;
@@ -13,6 +14,8 @@
1314
import java.io.File;
1415
import java.io.FileOutputStream;
1516
import java.io.IOException;
17+
import java.util.HashMap;
18+
import java.util.Map;
1619

1720
import com.itextpdf.test.annotations.type.IntegrationTest;
1821
import org.junit.Assert;
@@ -51,4 +54,23 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
5154
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
5255
}
5356

57+
@Test
58+
public void barcode02Test() throws IOException, PdfException, InterruptedException {
59+
String filename = "barcodeDataMatrix2.pdf";
60+
PdfWriter writer = new PdfWriter(new FileOutputStream( destinationFolder +filename));
61+
PdfDocument document = new PdfDocument(writer);
62+
63+
64+
65+
PdfPage page1 = document.addNewPage();
66+
PdfCanvas canvas = new PdfCanvas(page1);
67+
BarcodeDataMatrix barcode2 = new BarcodeDataMatrix("дима","UTF-8");
68+
barcode2.placeBarcode(canvas, Color.GREEN, 10);
69+
document.close();
70+
71+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
72+
73+
74+
}
75+
5476
}

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeQRCodeTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.File;
1515
import java.io.FileOutputStream;
1616
import java.io.IOException;
17+
import java.nio.charset.Charset;
1718
import java.util.HashMap;
1819
import java.util.Map;
1920

@@ -33,7 +34,7 @@ public class BarcodeQRCodeTest {
3334
static public void beforeClass() {
3435
File dir = new File(destinationFolder);
3536
dir.mkdirs();
36-
for(File file: dir.listFiles())
37+
for (File file : dir.listFiles())
3738
file.delete();
3839
}
3940

@@ -55,4 +56,24 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
5556
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
5657
}
5758

59+
@Test
60+
public void barcode02Test() throws IOException, PdfException, InterruptedException {
61+
String filename ="barcodeQRCode02.pdf";
62+
PdfWriter writer = new PdfWriter(new FileOutputStream( destinationFolder + filename));
63+
PdfDocument document = new PdfDocument(writer);
64+
65+
PdfPage page1 = document.addNewPage();
66+
PdfCanvas canvas = new PdfCanvas(page1);
67+
Map<EncodeHintType, Object> hints = new HashMap<>();
68+
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
69+
BarcodeQRCode barcode1 = new BarcodeQRCode("дима", hints);
70+
barcode1.placeBarcode(canvas, Color.GRAY, 12);
71+
72+
document.close();
73+
74+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
75+
76+
77+
}
78+
5879
}
Binary file not shown.
Binary file not shown.

forms/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-RC.20160201</version>
8+
<version>7.0.0-RC.20160321</version>
99
</parent>
1010

1111
<artifactId>forms</artifactId>

0 commit comments

Comments
 (0)