Implements the code 128 and UCC/EAN-128. Other symbologies are allowed in raw mode.
The code types allowed are:
- CODE128 - plain barcode 128.
- CODE128_UCC - support for UCC/EAN-128 with a full list of AI.
- CODE128_RAW - raw mode. The code attribute has the actual codes from 0
to 105 followed by '\uffff' and the human readable text.
The default parameters are:
x = 0.8f;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
textAlignment = Element.ALIGN_CENTER;
codeType = CODE128;
BARS
(package private) static byte[][] BARS
The bars to generate the code.
BARS_STOP
(package private) static byte[] BARS_STOP
The stop bars.
CODE_A
public static final char CODE_A
CODE_AB_TO_C
public static final char CODE_AB_TO_C
The charset code change.
CODE_AC_TO_B
public static final char CODE_AC_TO_B
The charset code change.
CODE_BC_TO_A
public static final char CODE_BC_TO_A
The charset code change.
CODE_C
public static final char CODE_C
DEL
public static final char DEL
FNC1
public static final char FNC1
FNC1_INDEX
public static final char FNC1_INDEX
The code for UCC/EAN-128.
FNC2
public static final char FNC2
FNC3
public static final char FNC3
FNC4
public static final char FNC4
SHIFT
public static final char SHIFT
STARTA
public static final char STARTA
STARTB
public static final char STARTB
STARTC
public static final char STARTC
START_A
public static final char START_A
The start code.
START_B
public static final char START_B
The start code.
START_C
public static final char START_C
The start code.
createAwtImage
public java.awt.Image createAwtImage(Color foreground,
Color background)
Creates a java.awt.Image
. This image only
contains the bars without any text.
- createAwtImage in interface Barcode
foreground
- the color of the barsbackground
- the color of the background
getBarcodeSize
public Rectangle getBarcodeSize()
Gets the maximum area that the barcode and the text, if
any, will occupy. The lower left corner is always (0, 0).
- getBarcodeSize in interface Barcode
- the size the barcode occupies.
getBarsCode128Raw
public static byte[] getBarsCode128Raw(String text)
Generates the bars. The input has the actual barcodes, not
the human readable text.
getHumanReadableUCCEAN
public static String getHumanReadableUCCEAN(String code)
Gets the human readable text of a sequence of AI.
getPackedRawDigits
(package private) static String getPackedRawDigits(String text,
int textIndex,
int numDigits)
Packs the digits for charset C also considering FNC1. It assumes that all the parameters
are valid.
text
- the text to packtextIndex
- where to pack fromnumDigits
- the number of digits to pack. It is always an even number
- the packed digits, two digits per character
getRawText
public static String getRawText(String text,
boolean ucc)
Converts the human readable text to the characters needed to
create a barcode. Some optimization is done to get the shortest code.
text
- the text to convertucc
- true
if it is an UCC/EAN-128. In this case
the character FNC1 is added
- the code ready to be fed to getBarsCode128Raw()
isNextDigits
(package private) static boolean isNextDigits(String text,
int textIndex,
int numDigits)
Returns true
if the next numDigits
starting from index textIndex
are numeric skipping any FNC1.
text
- the text to checktextIndex
- where to check fromnumDigits
- the number of digits to check
placeBarcode
public Rectangle placeBarcode(PdfContentByte cb,
Color barColor,
Color textColor)
Places the barcode in a
PdfContentByte
. The
barcode is always placed at coodinates (0, 0). Use the
translation matrix to move it elsewhere.
The bars and text are written in the following colors:
barColor | textColor | Result |
---|
null | null | bars and text painted with current fill color |
barColor | null | bars and text painted with barColor |
null | textColor | bars painted with current color text painted with textColor |
barColor | textColor | bars painted with barColor text painted with textColor |
- placeBarcode in interface Barcode
cb
- the PdfContentByte
where the barcode will be placedbarColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
- the dimensions the barcode occupies
removeFNC1
public static String removeFNC1(String code)
Removes the FNC1 codes in the text.
setCode
public void setCode(String code)
Sets the code to generate. If it's an UCC code and starts with '(' it will
be split by the AI. This code in UCC mode is valid:
(01)00000090311314(10)ABC123(15)060916
- setCode in interface Barcode
code
- the code to generate