Skip to content

Commit 1ad59bf

Browse files
committed
[RELEASE] merging 'release/7.0.5' into 'master'
2 parents 7d045d4 + 910af67 commit 1ad59bf

File tree

368 files changed

+10517
-3427
lines changed

Some content is hidden

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

368 files changed

+10517
-3427
lines changed

barcodes/pom.xml

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
<?xml version="1.0"?>
1+
<?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">
3-
<modelVersion>4.0.0</modelVersion>
4-
5-
<parent>
6-
<groupId>com.itextpdf</groupId>
7-
<artifactId>root</artifactId>
8-
<version>7.0.4</version>
9-
</parent>
10-
11-
<artifactId>barcodes</artifactId>
12-
<name>iText 7 - barcodes</name>
13-
<url>http://itextpdf.com/</url>
3+
<modelVersion>4.0.0</modelVersion>
144

15-
<dependencies>
16-
<dependency>
17-
<groupId>com.itextpdf</groupId>
18-
<artifactId>pdftest</artifactId>
19-
<version>${project.version}</version>
20-
<scope>test</scope>
21-
</dependency>
22-
<dependency>
23-
<groupId>com.itextpdf</groupId>
24-
<artifactId>kernel</artifactId>
25-
<version>${project.version}</version>
26-
</dependency>
27-
</dependencies>
5+
<parent>
6+
<groupId>com.itextpdf</groupId>
7+
<artifactId>root</artifactId>
8+
<version>7.0.5</version>
9+
</parent>
2810

29-
<build>
30-
<plugins>
31-
<plugin>
32-
<groupId>org.apache.maven.plugins</groupId>
33-
<artifactId>maven-surefire-plugin</artifactId>
34-
<configuration>
35-
<groups>${unittests}</groups>
36-
</configuration>
37-
</plugin>
38-
<plugin>
39-
<groupId>org.apache.maven.plugins</groupId>
40-
<artifactId>maven-failsafe-plugin</artifactId>
41-
<configuration>
42-
<includes>
43-
<include>**/*Test.java</include>
44-
</includes>
45-
<groups>${integrationtests}</groups>
46-
</configuration>
47-
</plugin>
48-
</plugins>
49-
</build>
11+
<artifactId>barcodes</artifactId>
5012

13+
<name>iText 7 - barcodes</name>
14+
<url>http://itextpdf.com/</url>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.itextpdf</groupId>
19+
<artifactId>kernel</artifactId>
20+
<version>${project.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>com.itextpdf</groupId>
24+
<artifactId>pdftest</artifactId>
25+
<version>${project.version}</version>
26+
<scope>test</scope>
27+
</dependency>
28+
</dependencies>
29+
30+
<build>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-surefire-plugin</artifactId>
35+
<configuration>
36+
<groups>${unittests}</groups>
37+
</configuration>
38+
</plugin>
39+
<plugin>
40+
<groupId>org.apache.maven.plugins</groupId>
41+
<artifactId>maven-failsafe-plugin</artifactId>
42+
<configuration>
43+
<includes>
44+
<include>**/*Test.java</include>
45+
</includes>
46+
<groups>${integrationtests}</groups>
47+
</configuration>
48+
</plugin>
49+
</plugins>
50+
</build>
5151
</project>

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public class Barcode128 extends Barcode1D {
222222

223223
/**
224224
* Creates new Barcode128
225+
* @param document The document
225226
*/
226227
public Barcode128(PdfDocument document) {
227228
super(document);
@@ -252,8 +253,8 @@ public Barcode128CodeSet getCodeSet() {
252253

253254
/**
254255
* Removes the FNC1 codes in the text.
255-
* @param code the text to clean
256-
* @return the cleaned text
256+
* @param code The text to clean
257+
* @return The cleaned text
257258
*/
258259
public static String removeFNC1(String code) {
259260
int len = code.length();
@@ -531,8 +532,9 @@ public Rectangle getBarcodeSize() {
531532
* Places the barcode in a <CODE>PdfCanvas</CODE>. The
532533
* barcode is always placed at coordinates (0, 0). Use the
533534
* translation matrix to move it elsewhere.<p>
534-
* The bars and text are written in the following colors:<p>
535-
* <P><TABLE BORDER=1>
535+
* The bars and text are written in the following colors:
536+
* <br>
537+
* <TABLE BORDER=1 SUMMARY="barcode properties">
536538
* <TR>
537539
* <TH><P><CODE>barColor</CODE></TH>
538540
* <TH><P><CODE>textColor</CODE></TH>
@@ -656,7 +658,7 @@ public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
656658
/**
657659
* Sets the code to generate. If it's an UCC code and starts with '(' it will
658660
* be split by the AI. This code in UCC mode is valid:
659-
* <p/>
661+
* <br>
660662
* <code>(01)00000090311314(10)ABC123(15)060916</code>
661663
*
662664
* @param code the code to generate
@@ -711,8 +713,8 @@ public void setCode(String code) {
711713
*/
712714
@Override
713715
public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
714-
int f = foreground.getRGB();
715-
int g = background.getRGB();
716+
int f = (foreground == null) ? DEFAULT_BAR_FOREGROUND_COLOR.getRGB() : foreground.getRGB();
717+
int g = (background == null) ? DEFAULT_BAR_BACKGROUND_COLOR.getRGB() : background.getRGB();
716718
java.awt.Canvas canvas = new java.awt.Canvas();
717719
String bCode;
718720
if (codeType == CODE128_RAW) {

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ public abstract class Barcode1D {
5858
public static final int ALIGN_RIGHT = 2;
5959
public static final int ALIGN_CENTER = 3;
6060

61+
/**
62+
* The default color to draw if a bar is present.
63+
*/
64+
protected final java.awt.Color DEFAULT_BAR_FOREGROUND_COLOR = java.awt.Color.BLACK;
65+
/**
66+
* The default color to draw if a bar is not present.
67+
*/
68+
protected final java.awt.Color DEFAULT_BAR_BACKGROUND_COLOR = java.awt.Color.WHITE;
69+
6170
protected PdfDocument document;
6271

6372
/**
@@ -413,8 +422,9 @@ public void setCodeType(int codeType) {
413422
* Places the barcode in a <CODE>PdfCanvas</CODE>. The
414423
* barcode is always placed at coordinates (0, 0). Use the
415424
* translation matrix to move it elsewhere.<p>
416-
* The bars and text are written in the following colors:<p>
417-
* <P><TABLE BORDER=1>
425+
* The bars and text are written in the following colors:
426+
* <br>
427+
* <TABLE BORDER=1 SUMMARY="barcode properties">
418428
* <TR>
419429
* <TH><P><CODE>barColor</CODE></TH>
420430
* <TH><P><CODE>textColor</CODE></TH>
@@ -492,16 +502,16 @@ public void setAltText(String altText) {
492502
* Creates a <CODE>java.awt.Image</CODE>. This image only
493503
* contains the bars without any text.
494504
*
495-
* @param foreground the color of the bars
496-
* @param background the color of the background
505+
* @param foreground the color of the bars. If <CODE>null</CODE> defaults to {@link Barcode1D#DEFAULT_BAR_FOREGROUND_COLOR}
506+
* @param background the color of the background. If <CODE>null</CODE> defaults to {@link Barcode1D#DEFAULT_BAR_BACKGROUND_COLOR}
497507
* @return the image
498508
*/
499509
public abstract java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background);
500510

501511
/**
502512
* Creates a PdfFormXObject with the barcode. Default bar color and text color will be used.
503-
*
504-
* @return the XObject
513+
* @param document The document
514+
* @return The XObject
505515
* @see #createFormXObject(Color, Color, PdfDocument)
506516
*/
507517
public PdfFormXObject createFormXObject(PdfDocument document) {
@@ -511,8 +521,9 @@ public PdfFormXObject createFormXObject(PdfDocument document) {
511521
/**
512522
* Creates a PdfFormXObject with the barcode.
513523
*
514-
* @param barColor the color of the bars. It can be <CODE>null</CODE>
515-
* @param textColor the color of the text. It can be <CODE>null</CODE>
524+
* @param barColor The color of the bars. It can be <CODE>null</CODE>
525+
* @param textColor The color of the text. It can be <CODE>null</CODE>
526+
* @param document The document
516527
* @return the XObject
517528
* @see #placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
518529
*/
@@ -527,6 +538,7 @@ public PdfFormXObject createFormXObject(Color barColor, Color textColor, PdfDocu
527538
/**
528539
* Make the barcode occupy the specified width.
529540
* Usually this is achieved by adjusting bar widths.
541+
* @param width The width
530542
*/
531543
public void fitWidth(float width) {
532544
setX(x * width / getBarcodeSize().getWidth());

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public abstract class Barcode2D {
7676
* Creates a PdfFormXObject with the barcode.
7777
* Default foreground color will be used.
7878
*
79+
* @param document The document
7980
* @return the XObject.
8081
*/
8182
public PdfFormXObject createFormXObject(PdfDocument document) {
@@ -85,7 +86,8 @@ public PdfFormXObject createFormXObject(PdfDocument document) {
8586
/**
8687
* Creates a PdfFormXObject with the barcode.
8788
*
88-
* @param foreground the color of the pixels. It can be <CODE>null</CODE>
89+
* @param foreground The color of the pixels. It can be <CODE>null</CODE>
90+
* @param document The document
8991
* @return the XObject.
9092
*/
9193
public abstract PdfFormXObject createFormXObject(Color foreground, PdfDocument document);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public class Barcode39 extends Barcode1D {
130130

131131
/**
132132
* Creates a new Barcode39.
133+
* @param document The document
133134
*/
134135
public Barcode39(PdfDocument document) {
135136
super(document);
@@ -258,8 +259,9 @@ public Rectangle getBarcodeSize() {
258259
* Places the barcode in a <CODE>PdfCanvas</CODE>. The
259260
* barcode is always placed at coordinates (0, 0). Use the
260261
* translation matrix to move it elsewhere.<p>
261-
* The bars and text are written in the following colors:<p>
262-
* <P><TABLE BORDER=1>
262+
* The bars and text are written in the following colors:
263+
* <br>
264+
* <TABLE BORDER=1 SUMMARY="barcode properties">
263265
* <TR>
264266
* <TH><P><CODE>barColor</CODE></TH>
265267
* <TH><P><CODE>textColor</CODE></TH>
@@ -382,8 +384,8 @@ public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
382384
*/
383385
@Override
384386
public Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
385-
int f = foreground.getRGB();
386-
int g = background.getRGB();
387+
int f = (foreground == null) ? DEFAULT_BAR_FOREGROUND_COLOR.getRGB() : foreground.getRGB();
388+
int g = (background == null) ? DEFAULT_BAR_BACKGROUND_COLOR.getRGB() : background.getRGB();
387389
java.awt.Canvas canvas = new java.awt.Canvas();
388390
String bCode = code;
389391
if (extended) {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public class BarcodeCodabar extends Barcode1D {
9090

9191
/**
9292
* Creates a new BarcodeCodabar.
93+
* @param document The document
9394
*/
9495
public BarcodeCodabar(PdfDocument document) {
9596
super(document);
@@ -191,8 +192,9 @@ public Rectangle getBarcodeSize() {
191192
* Places the barcode in a <CODE>PdfCanvas</CODE>. The
192193
* barcode is always placed at coordinates (0, 0). Use the
193194
* translation matrix to move it elsewhere.<p>
194-
* The bars and text are written in the following colors:<p>
195-
* <P><TABLE BORDER=1>
195+
* The bars and text are written in the following colors:
196+
* <br>
197+
* <TABLE BORDER=1 SUMMARY="barcode properties">
196198
* <TR>
197199
* <TH><P><CODE>barColor</CODE></TH>
198200
* <TH><P><CODE>textColor</CODE></TH>
@@ -311,8 +313,8 @@ public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
311313
* @return the image
312314
*/
313315
public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
314-
int f = foreground.getRGB();
315-
int g = background.getRGB();
316+
int f = (foreground == null) ? DEFAULT_BAR_FOREGROUND_COLOR.getRGB() : foreground.getRGB();
317+
int g = (background == null) ? DEFAULT_BAR_BACKGROUND_COLOR.getRGB() : background.getRGB();
316318
java.awt.Canvas canvas = new java.awt.Canvas();
317319

318320
byte[] bars = getBarsCodabar(generateChecksum ? calculateChecksum(code) : code);

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ public PdfFormXObject createFormXObject(Color foreground, PdfDocument document)
225225
/**
226226
* Creates a PdfFormXObject with the barcode with given module width and module height.
227227
*
228-
* @param foreground the color of the pixels. It can be <CODE>null</CODE>
229-
* @param moduleSide the side (width and height) of the pixels.
228+
* @param foreground The color of the pixels. It can be <CODE>null</CODE>
229+
* @param moduleSide The side (width and height) of the pixels.
230+
* @param document The document
230231
* @return the XObject.
231232
*/
232233
public PdfFormXObject createFormXObject(Color foreground, float moduleSide, PdfDocument document) {
@@ -302,6 +303,9 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b
302303

303304
/**
304305
* Gets the barcode size
306+
* @param moduleHeight The height of the module
307+
* @param moduleWidth The width of the module
308+
* @return The size of the barcode
305309
*/
306310
public Rectangle getBarcodeSize(float moduleHeight, float moduleWidth) {
307311
return new Rectangle(0, 0, (width + 2 * ws) * moduleHeight, (height + 2 * ws) * moduleWidth);
@@ -312,7 +316,7 @@ public Rectangle getBarcodeSize(float moduleHeight, float moduleWidth) {
312316
*
313317
* @param text the text
314318
* @return the status of the generation. It can be one of this values:
315-
* <p/>
319+
*
316320
* <CODE>DM_NO_ERROR</CODE> - no error.<br>
317321
* <CODE>DM_ERROR_TEXT_TOO_BIG</CODE> - the text is too big for the symbology capabilities.<br>
318322
* <CODE>DM_ERROR_INVALID_SQUARE</CODE> - the dimensions given for the symbol are illegal.<br>
@@ -335,7 +339,7 @@ public int setCode(String text) {
335339
* @param textOffset the offset to the start of the text
336340
* @param textSize the text size
337341
* @return the status of the generation. It can be one of this values:
338-
* <p/>
342+
*
339343
* <CODE>DM_NO_ERROR</CODE> - no error.<br>
340344
* <CODE>DM_ERROR_TEXT_TOO_BIG</CODE> - the text is too big for the symbology capabilities.<br>
341345
* <CODE>DM_ERROR_INVALID_SQUARE</CODE> - the dimensions given for the symbol are illegal.<br>
@@ -406,7 +410,7 @@ public int getHeight() {
406410

407411
/**
408412
* 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.
409-
* <p/>
413+
*
410414
* The allowed dimensions are (height, width):<p>
411415
* 10, 10<br>
412416
* 12, 12<br>
@@ -457,7 +461,7 @@ public int getWidth() {
457461

458462
/**
459463
* 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.
460-
* <p/>
464+
*
461465
* The allowed dimensions are (height, width):<p>
462466
* 10, 10<br>
463467
* 12, 12<br>
@@ -535,7 +539,7 @@ public int getOptions() {
535539
* <CODE>DM_X12</CODE> - X12 encodation<br>
536540
* <CODE>DM_EDIFACT</CODE> - EDIFACT encodation<br>
537541
* <CODE>DM_RAW</CODE> - no encodation. The bytes provided are already encoded and will be added directly to the barcode, using padding if needed. It assumes that the encodation state is left at ASCII after the last byte.<br>
538-
* <p/>
542+
* <br>
539543
* One of:<br>
540544
* <CODE>DM_EXTENSION</CODE> - allows extensions to be embedded at the start of the text:<p>
541545
* exxxxxx - ECI number xxxxxx<br>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public class BarcodeEAN extends Barcode1D {
208208

209209
/**
210210
* Creates new BarcodeEAN
211+
* @param document The document
211212
*/
212213
public BarcodeEAN(PdfDocument document) {
213214
super(document);
@@ -541,8 +542,9 @@ public Rectangle getBarcodeSize() {
541542
* Places the barcode in a <CODE>PdfCanvas</CODE>. The
542543
* barcode is always placed at coordinates (0, 0). Use the
543544
* translation matrix to move it elsewhere.<p>
544-
* The bars and text are written in the following colors:<p>
545-
* <P><TABLE BORDER=1>
545+
* The bars and text are written in the following colors:
546+
* <br>
547+
* <TABLE BORDER=1 SUMMARY="barcode properties">
546548
* <TR>
547549
* <TH><P><CODE>barColor</CODE></TH>
548550
* <TH><P><CODE>textColor</CODE></TH>
@@ -729,8 +731,8 @@ public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
729731
*/
730732
@Override
731733
public Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
732-
int f = foreground.getRGB();
733-
int g = background.getRGB();
734+
int f = (foreground == null) ? DEFAULT_BAR_FOREGROUND_COLOR.getRGB() : foreground.getRGB();
735+
int g = (background == null) ? DEFAULT_BAR_BACKGROUND_COLOR.getRGB() : background.getRGB();
734736
java.awt.Canvas canvas = new java.awt.Canvas();
735737

736738
int width;

0 commit comments

Comments
 (0)