CODABAR
public static final int CODABAR
A type of barcode
CODE128
public static final int CODE128
A type of barcode
CODE128_RAW
public static final int CODE128_RAW
A type of barcode
CODE128_UCC
public static final int CODE128_UCC
A type of barcode
EAN13
public static final int EAN13
A type of barcode
EAN8
public static final int EAN8
A type of barcode
PLANET
public static final int PLANET
A type of barcode
POSTNET
public static final int POSTNET
A type of barcode
SUPP2
public static final int SUPP2
A type of barcode
SUPP5
public static final int SUPP5
A type of barcode
UPCA
public static final int UPCA
A type of barcode
UPCE
public static final int UPCE
A type of barcode
barHeight
protected float barHeight
The height of the bars.
baseline
protected float baseline
If positive, the text distance under the bars. If zero or negative,
the text distance above the bars.
checksumText
protected boolean checksumText
Shows the generated checksum in the the text.
code
protected String code
The code to generate.
codeType
protected int codeType
The code type.
extended
protected boolean extended
Generates extended barcode 39.
font
protected BaseFont font
The text font. null
if no text.
generateChecksum
protected boolean generateChecksum
The optional checksum generation.
guardBars
protected boolean guardBars
Show the guard bars for barcode EAN.
inkSpreading
protected float inkSpreading
The ink spreading.
n
protected float n
The bar multiplier for wide bars or the distance between
bars for Postnet and Planet.
size
protected float size
The size of the text or the height of the shorter bar
in Postnet.
startStopText
protected boolean startStopText
Show the start and stop character '*' in the text for
the barcode 39 or 'ABCD' for codabar.
textAlignment
protected int textAlignment
The text alignment. Can be Element.ALIGN_LEFT
,
Element.ALIGN_CENTER
or Element.ALIGN_RIGHT
.
x
protected float x
The minimum bar width.
createAwtImage
public abstract java.awt.Image createAwtImage(Color foreground,
Color background)
Creates a java.awt.Image
. This image only
contains the bars without any text.
foreground
- the color of the barsbackground
- the color of the background
createImageWithBarcode
public Image createImageWithBarcode(PdfContentByte cb,
Color barColor,
Color textColor)
Creates an Image
with the barcode.
cb
- the PdfContentByte
to create the Image
. It
serves no other usebarColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
placeBarcode(PdfContentByte cb, Color barColor, Color textColor)
createTemplateWithBarcode
public PdfTemplate createTemplateWithBarcode(PdfContentByte cb,
Color barColor,
Color textColor)
Creates a template with the barcode.
cb
- the PdfContentByte
to create the template. It
serves no other usebarColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
placeBarcode(PdfContentByte cb, Color barColor, Color textColor)
getBarHeight
public float getBarHeight()
Gets the height of the bars.
getBarcodeSize
public abstract Rectangle getBarcodeSize()
Gets the maximum area that the barcode and the text, if
any, will occupy. The lower left corner is always (0, 0).
- the size the barcode occupies.
getBaseline
public float getBaseline()
Gets the text baseline.
If positive, the text distance under the bars. If zero or negative,
the text distance above the bars.
getCode
public String getCode()
Gets the code to generate.
getCodeType
public int getCodeType()
Gets the code type.
getFont
public BaseFont getFont()
Gets the text font. null
if no text.
- the text font.
null
if no text
getInkSpreading
public float getInkSpreading()
Gets the amount of ink spreading.
getN
public float getN()
Gets the bar multiplier for wide bars.
- the bar multiplier for wide bars
getSize
public float getSize()
Gets the size of the text.
getTextAlignment
public int getTextAlignment()
Gets the text alignment. Can be Element.ALIGN_LEFT
,
Element.ALIGN_CENTER
or Element.ALIGN_RIGHT
.
getX
public float getX()
Gets the minimum bar width.
isChecksumText
public boolean isChecksumText()
Gets the property to show the generated checksum in the the text.
- value of property checksumText
isExtended
public boolean isExtended()
Gets the property to generate extended barcode 39.
- value of property extended.
isGenerateChecksum
public boolean isGenerateChecksum()
Gets the optional checksum generation.
- the optional checksum generation
isGuardBars
public boolean isGuardBars()
Gets the property to show the guard bars for barcode EAN.
- value of property guardBars
isStartStopText
public boolean isStartStopText()
Sets the property to show the start and stop character '*' in the text for
the barcode 39.
- value of property startStopText
placeBarcode
public abstract Rectangle placeBarcode(PdfContentByte cb,
Color barColor,
Color textColor)
Places the barcode in a
PdfContentByte
. The
barcode is always placed at coodinates (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 with textColor |
barColor | textColor | bars painted with barColor text painted with textColor |
cb
- the PdfContentByte
where the barcode will be placedbarColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
- the dimensions the barcode occupies
setBarHeight
public void setBarHeight(float barHeight)
Sets the height of the bars.
barHeight
- the height of the bars
setBaseline
public void setBaseline(float baseline)
Sets the text baseline.
If positive, the text distance under the bars. If zero or negative,
the text distance above the bars.
setChecksumText
public void setChecksumText(boolean checksumText)
Sets the property to show the generated checksum in the the text.
checksumText
- new value of property checksumText
setCode
public void setCode(String code)
Sets the code to generate.
code
- the code to generate
setCodeType
public void setCodeType(int codeType)
Sets the code type.
setExtended
public void setExtended(boolean extended)
Sets the property to generate extended barcode 39.
extended
- new value of property extended
setFont
public void setFont(BaseFont font)
Sets the text font.
font
- the text font. Set to null
to suppress any text
setGenerateChecksum
public void setGenerateChecksum(boolean generateChecksum)
Setter for property generateChecksum.
generateChecksum
- New value of property generateChecksum.
setGuardBars
public void setGuardBars(boolean guardBars)
Sets the property to show the guard bars for barcode EAN.
guardBars
- new value of property guardBars
setInkSpreading
public void setInkSpreading(float inkSpreading)
Sets the amount of ink spreading. This value will be subtracted
to the width of each bar. The actual value will depend on the ink
and the printing medium.
inkSpreading
- the ink spreading
setN
public void setN(float n)
Sets the bar multiplier for wide bars.
n
- the bar multiplier for wide bars
setSize
public void setSize(float size)
Sets the size of the text.
size
- the size of the text
setStartStopText
public void setStartStopText(boolean startStopText)
Gets the property to show the start and stop character '*' in the text for
the barcode 39.
startStopText
- new value of property startStopText
setTextAlignment
public void setTextAlignment(int textAlignment)
Sets the text alignment. Can be Element.ALIGN_LEFT
,
Element.ALIGN_CENTER
or Element.ALIGN_RIGHT
.
textAlignment
- the text alignment
setX
public void setX(float x)
Sets the minimum bar width.
x
- the minimum bar width