Package com.itextpdf.barcodes
Class Barcode128
java.lang.Object
com.itextpdf.barcodes.Barcode1D
com.itextpdf.barcodes.Barcode128
BarCode 128 is a high-density linear barcode symbology defined in ISO/IEC 15417:2007. It is used for alphanumeric or numeric-only barcodes. It can encode all 128 characters of ASCII
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The code set to be used to start encoding. -
Field Summary
Modifier and TypeFieldDescriptionstatic final char
static final char
The charset code change.static final char
The charset code change.static final char
The charset code change.static final char
static final int
A type of barcodestatic final int
A type of barcodestatic final int
A type of barcodestatic final char
static final char
static final char
The code for UCC/EAN-128.static final char
static final char
static final char
static final char
static final char
The start code.static final char
The start code.static final char
The start code.static final char
static final char
static final char
Fields inherited from class com.itextpdf.barcodes.Barcode1D
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, altText, barHeight, baseline, checksumText, code, codeType, DEFAULT_BAR_BACKGROUND_COLOR, DEFAULT_BAR_FOREGROUND_COLOR, document, extended, font, generateChecksum, guardBars, inkSpreading, n, size, startStopText, textAlignment, x
-
Constructor Summary
ConstructorDescriptionBarcode128
(PdfDocument document) Creates new Barcode128.Barcode128
(PdfDocument document, PdfFont font) Creates new Barcode128, which will use the provided font -
Method Summary
Modifier and TypeMethodDescriptioncreateAwtImage
(Color foreground, Color background) Creates ajava.awt.Image
.Gets the maximum area that the barcode and the text, if any, will occupy.static byte[]
getBarsCode128Raw
(String text) Generates the bars.Get the code set that is used.static String
getHumanReadableUCCEAN
(String code) Gets the human readable text of a sequence of AI.static String
getRawText
(String text, boolean ucc) Converts the human readable text to the characters needed to create a barcode.static String
getRawText
(String text, boolean ucc, Barcode128.Barcode128CodeSet codeSet) Converts the human readable text to the characters needed to create a barcode using the specified code set.placeBarcode
(PdfCanvas canvas, Color barColor, Color textColor) Places the barcode in aPdfCanvas
.static String
removeFNC1
(String code) Removes the FNC1 codes in the text.void
Sets the code to generate.void
setCodeSet
(Barcode128.Barcode128CodeSet codeSet) Sets the code set to use.Methods inherited from class com.itextpdf.barcodes.Barcode1D
createFormXObject, createFormXObject, fitWidth, getAltText, getBarHeight, getBaseline, getCode, getCodeType, getDescender, getFont, getInkSpreading, getN, getSize, getTextAlignment, getX, isChecksumText, isExtended, isGenerateChecksum, isGuardBars, isStartStopText, setAltText, setBarHeight, setBaseline, setChecksumText, setCodeType, setExtended, setFont, setGenerateChecksum, setGuardBars, setInkSpreading, setN, setSize, setStartStopText, setTextAlignment, setX
-
Field Details
-
CODE128
public static final int CODE128A type of barcode- See Also:
-
CODE128_UCC
public static final int CODE128_UCCA type of barcode- See Also:
-
CODE128_RAW
public static final int CODE128_RAWA type of barcode- See Also:
-
CODE_AB_TO_C
public static final char CODE_AB_TO_CThe charset code change.- See Also:
-
CODE_AC_TO_B
public static final char CODE_AC_TO_BThe charset code change.- See Also:
-
CODE_BC_TO_A
public static final char CODE_BC_TO_AThe charset code change.- See Also:
-
FNC1_INDEX
public static final char FNC1_INDEXThe code for UCC/EAN-128.- See Also:
-
START_A
public static final char START_AThe start code.- See Also:
-
START_B
public static final char START_BThe start code.- See Also:
-
START_C
public static final char START_CThe start code.- See Also:
-
FNC1
public static final char FNC1- See Also:
-
DEL
public static final char DEL- See Also:
-
FNC3
public static final char FNC3- See Also:
-
FNC2
public static final char FNC2- See Also:
-
SHIFT
public static final char SHIFT- See Also:
-
CODE_C
public static final char CODE_C- See Also:
-
CODE_A
public static final char CODE_A- See Also:
-
FNC4
public static final char FNC4- See Also:
-
STARTA
public static final char STARTA- See Also:
-
STARTB
public static final char STARTB- See Also:
-
STARTC
public static final char STARTC- See Also:
-
-
Constructor Details
-
Barcode128
Creates new Barcode128. To generate the font thePdfDocument.getDefaultFont()
will be implicitly called. If you want to use this barcode in PDF/A documents, please consider usingBarcode128(PdfDocument, PdfFont)
.- Parameters:
-
document
- The document to which the barcode will be added
-
Barcode128
Creates new Barcode128, which will use the provided font- Parameters:
-
document
- The document to which the barcode will be added -
font
- The font to use
-
-
Method Details
-
setCodeSet
Sets the code set to use.- Parameters:
-
codeSet
- the code set to use.
-
getCodeSet
Get the code set that is used.- Returns:
- the code set.
-
removeFNC1
Removes the FNC1 codes in the text.- Parameters:
-
code
- The text to clean - Returns:
- The cleaned text
-
getHumanReadableUCCEAN
Gets the human readable text of a sequence of AI.- Parameters:
-
code
- the text - Returns:
- the human readable text
-
getRawText
Converts the human readable text to the characters needed to create a barcode using the specified code set.- Parameters:
-
text
- the text to convert -
ucc
-true
if it is an UCC/EAN-128. In this case the character FNC1 is added -
codeSet
- forced code set, or AUTO for optimized barcode. - Returns:
- the code ready to be fed to getBarsCode128Raw()
-
getRawText
Converts the human readable text to the characters needed to create a barcode. Some optimization is done to get the shortest code.- Parameters:
-
text
- the text to convert -
ucc
-true
if it is an UCC/EAN-128. In this case the character FNC1 is added - Returns:
- the code ready to be fed to getBarsCode128Raw()
-
getBarsCode128Raw
Generates the bars. The input has the actual barcodes, not the human readable text.- Parameters:
-
text
- the barcode - Returns:
- the bars
-
getBarcodeSize
Gets the maximum area that the barcode and the text, if any, will occupy. The lower left corner is always (0, 0).- Specified by:
-
getBarcodeSize
in classBarcode1D
- Returns:
- the size the barcode occupies.
-
placeBarcode
Places the barcode in aPdfCanvas
. The barcode is always placed at coordinates (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 withtextColor
barColor
textColor
bars painted with barColor
text painted withtextColor
- Specified by:
-
placeBarcode
in classBarcode1D
- Parameters:
-
canvas
- thePdfCanvas
where the barcode will be placed -
barColor
- the color of the bars. It can benull
-
textColor
- the color of the text. It can benull
- Returns:
- the dimensions the barcode occupies
-
setCode
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
-
createAwtImage
Creates ajava.awt.Image
. This image only contains the bars without any text.- Specified by:
-
createAwtImage
in classBarcode1D
- Parameters:
-
foreground
- the color of the bars -
background
- the color of the background - Returns:
- the image
-