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
Nested ClassesModifier and TypeClassDescriptionstatic enumThe code set to be used to start encoding. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[][]The bars to generate the code.private static final byte[]The stop bars.static final charstatic final charThe charset code change.static final charThe charset code change.static final charThe charset code change.static final charstatic final intA type of barcodestatic final intA type of barcodestatic final intA type of barcodeprivate Barcode128.Barcode128CodeSetstatic final charstatic final charstatic final charThe code for UCC/EAN-128.static final charstatic final charstatic final charstatic final charstatic final charThe start code.static final charThe start code.static final charThe start code.static final charstatic final charstatic final charFields inherited from class 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
ConstructorsConstructorDescriptionBarcode128(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 StringgetHumanReadableUCCEAN(String code) Gets the human readable text of a sequence of AI.(package private) static StringgetPackedRawDigits(String text, int textIndex, int numDigits) Packs the digits for charset C also considering FNC1.static StringgetRawText(String text, boolean ucc) Converts the human readable text to the characters needed to create a barcode.static StringgetRawText(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.private static char(package private) static booleanisNextDigits(String text, int textIndex, int numDigits) Returnstrueif the nextnumDigitsstarting from indextextIndexare numeric skipping any FNC1.placeBarcode(PdfCanvas canvas, Color barColor, Color textColor) Places the barcode in aPdfCanvas.static StringremoveFNC1(String code) Removes the FNC1 codes in the text.voidSets the code to generate.voidsetCodeSet(Barcode128.Barcode128CodeSet codeSet) Sets the code set to use.Methods inherited from class 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:
-
BARS
private static final byte[][] BARSThe bars to generate the code. -
BARS_STOP
private static final byte[] BARS_STOPThe stop bars. -
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:
-
ais
-
codeSet
-
-
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 addedfont- 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
-
getHumanReadableUCCEAN
-
getRawText
Converts the human readable text to the characters needed to create a barcode using the specified code set.- Parameters:
text- the text to convertucc-trueif it is an UCC/EAN-128. In this case the character FNC1 is addedcodeSet- 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 convertucc-trueif 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:
getBarcodeSizein 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:
barColortextColorResult nullnullbars and text painted with current fill color barColornullbars and text painted with barColornulltextColorbars painted with current color
text painted withtextColorbarColortextColorbars painted with barColor
text painted withtextColor- Specified by:
placeBarcodein classBarcode1D- Parameters:
canvas- thePdfCanvaswhere the barcode will be placedbarColor- the color of the bars. It can benulltextColor- the color of the text. It can benull- Returns:
- the dimensions the barcode occupies
-
setCode
-
createAwtImage
Creates ajava.awt.Image. This image only contains the bars without any text.- Specified by:
createAwtImagein classBarcode1D- Parameters:
foreground- the color of the barsbackground- the color of the background- Returns:
- the image
-
getStartSymbol
-
isNextDigits
Returnstrueif the nextnumDigitsstarting from indextextIndexare numeric skipping any FNC1.- Parameters:
text- the text to checktextIndex- where to check fromnumDigits- the number of digits to check- Returns:
- the check result
-
getPackedRawDigits
Packs the digits for charset C also considering FNC1. It assumes that all the parameters are valid.- Parameters:
text- the text to packtextIndex- where to pack fromnumDigits- the number of digits to pack. It is always an even number- Returns:
- the packed digits, two digits per character
-