Package com.itextpdf.barcodes
Class BarcodePostnet
- java.lang.Object
-
- com.itextpdf.barcodes.Barcode1D
-
- com.itextpdf.barcodes.BarcodePostnet
-
public class BarcodePostnet extends Barcode1D
POSTNET (Postal Numeric Encoding Technique) is a barcode symbology used by the United States Postal Service to assist in directing mail. The ZIP Code or ZIP+4 code is encoded in half- and full-height bars.[1] Most often, the delivery point is added, usually being the last two digits of the address or PO box number.
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[][]BARSThe bars for each character.static intTYPE_PLANETstatic intTYPE_POSTNET-
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
Constructors Constructor Description BarcodePostnet(PdfDocument document)Creates newBarcodePostnetinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.ImagecreateAwtImage(java.awt.Color foreground, java.awt.Color background)Creates ajava.awt.Image.voidfitWidth(float width)Make the barcode occupy the specified width.RectanglegetBarcodeSize()Gets the maximum area that the barcode and the text, if any, will occupy.static byte[]getBarsPostnet(java.lang.String text)Creates the bars for Postnet.RectangleplaceBarcode(PdfCanvas canvas, Color barColor, Color textColor)Places the barcode in aPdfCanvas.-
Methods inherited from class com.itextpdf.barcodes.Barcode1D
createFormXObject, createFormXObject, getAltText, getBarHeight, getBaseline, getCode, getCodeType, getDescender, getFont, getInkSpreading, getN, getSize, getTextAlignment, getX, isChecksumText, isExtended, isGenerateChecksum, isGuardBars, isStartStopText, setAltText, setBarHeight, setBaseline, setChecksumText, setCode, setCodeType, setExtended, setFont, setGenerateChecksum, setGuardBars, setInkSpreading, setN, setSize, setStartStopText, setTextAlignment, setX
-
-
-
-
Field Detail
-
TYPE_POSTNET
public static final int TYPE_POSTNET
- See Also:
- Constant Field Values
-
TYPE_PLANET
public static final int TYPE_PLANET
- See Also:
- Constant Field Values
-
BARS
private static final byte[][] BARS
The bars for each character.
-
-
Constructor Detail
-
BarcodePostnet
public BarcodePostnet(PdfDocument document)
Creates newBarcodePostnetinstance.- Parameters:
document- The document
-
-
Method Detail
-
getBarsPostnet
public static byte[] getBarsPostnet(java.lang.String text)
Creates the bars for Postnet.- Parameters:
text- the code to be created without checksum- Returns:
- the bars
-
getBarcodeSize
public Rectangle getBarcodeSize()
Description copied from class:Barcode1DGets 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.
-
fitWidth
public void fitWidth(float width)
Description copied from class:Barcode1DMake the barcode occupy the specified width. Usually this is achieved by adjusting bar widths.
-
placeBarcode
public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
Description copied from class:Barcode1DPlaces 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
-
createAwtImage
public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background)Description copied from class:Barcode1DCreates ajava.awt.Image. This image only contains the bars without any text.- Specified by:
createAwtImagein classBarcode1D- Parameters:
foreground- the color of the bars. Ifnulldefaults toBarcode1D.DEFAULT_BAR_FOREGROUND_COLORbackground- the color of the background. Ifnulldefaults toBarcode1D.DEFAULT_BAR_BACKGROUND_COLOR- Returns:
- the image
-
-