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
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
-
Method Summary
Modifier and TypeMethodDescriptioncreateAwtImage
(Color foreground, Color background) Creates ajava.awt.Image
.void
fitWidth
(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 newBarcodePostnet
instance.- 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:Barcode1D
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.
-
fitWidth
public void fitWidth(float width) Description copied from class:Barcode1D
Make the barcode occupy the specified width. Usually this is achieved by adjusting bar widths. -
placeBarcode
Description copied from class:Barcode1D
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
-
createAwtImage
Description copied from class:Barcode1D
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. Ifnull
defaults toBarcode1D.DEFAULT_BAR_FOREGROUND_COLOR
-
background
- the color of the background. Ifnull
defaults toBarcode1D.DEFAULT_BAR_BACKGROUND_COLOR
- Returns:
- the image
-