Package com.itextpdf.barcodes
Class BarcodePostnet
java.lang.Object
com.itextpdf.barcodes.Barcode1D
com.itextpdf.barcodes.BarcodePostnet
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
FieldsFields 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 -
Method Summary
Modifier and TypeMethodDescriptioncreateAwtImage(Color foreground, Color background) Creates ajava.awt.Image.voidfitWidth(float width) Make the barcode occupy the specified width.Gets the maximum area that the barcode and the text, if any, will occupy.static byte[]getBarsPostnet(String text) Creates the bars for Postnet.placeBarcode(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 Details
-
TYPE_POSTNET
public static final int TYPE_POSTNET- See Also:
-
TYPE_PLANET
public static final int TYPE_PLANET- See Also:
-
-
Constructor Details
-
BarcodePostnet
Creates newBarcodePostnetinstance.- Parameters:
-
document- The document
-
-
Method Details
-
getBarsPostnet
Creates the bars for Postnet.- Parameters:
-
text- the code to be created without checksum - Returns:
- the bars
-
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
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 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
-
createAwtImage
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_COLOR -
background- the color of the background. Ifnulldefaults toBarcode1D.DEFAULT_BAR_BACKGROUND_COLOR - Returns:
- the image
-