public abstract class Barcode extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
altText
The alternate text to be used, if present.
|
protected float |
barHeight
The height of the bars.
|
protected float |
baseline
If positive, the text distance under the bars.
|
protected boolean |
checksumText
Shows the generated checksum in the the text.
|
static int |
CODABAR
A type of barcode
|
protected String |
code
The code to generate.
|
static int |
CODE128
A type of barcode
|
static int |
CODE128_RAW
A type of barcode
|
static int |
CODE128_UCC
A type of barcode
|
protected int |
codeType
The code type.
|
static int |
EAN13
A type of barcode
|
static int |
EAN8
A type of barcode
|
protected boolean |
extended
Generates extended barcode 39.
|
protected BaseFont |
font
The text font.
|
protected boolean |
generateChecksum
The optional checksum generation.
|
protected boolean |
guardBars
Show the guard bars for barcode EAN.
|
protected float |
inkSpreading
The ink spreading.
|
protected float |
n
The bar multiplier for wide bars or the distance between bars for Postnet and Planet.
|
static int |
PLANET
A type of barcode
|
static int |
POSTNET
A type of barcode
|
protected float |
size
The size of the text or the height of the shorter bar in Postnet.
|
protected boolean |
startStopText
Show the start and stop character '*' in the text for the barcode 39 or 'ABCD' for codabar.
|
static int |
SUPP2
A type of barcode
|
static int |
SUPP5
A type of barcode
|
protected int |
textAlignment
The text alignment.
|
static int |
UPCA
A type of barcode
|
static int |
UPCE
A type of barcode
|
protected float |
x
The minimum bar width.
|
Constructor and Description |
---|
Barcode() |
Modifier and Type | Method and Description |
---|---|
abstract Image |
createAwtImage(Color foreground, Color background)
Creates a java.awt.Image .
|
Image |
createImageWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
Creates an Image with the barcode.
|
PdfTemplate |
createTemplateWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
Creates a template with the barcode.
|
String |
getAltText()
Gets the alternate text.
|
abstract Rectangle |
getBarcodeSize()
Gets the maximum area that the barcode and the text, if any, will occupy.
|
float |
getBarHeight()
Gets the height of the bars.
|
float |
getBaseline()
Gets the text baseline.
|
String |
getCode()
Gets the code to generate.
|
int |
getCodeType()
Gets the code type.
|
BaseFont |
getFont()
Gets the text font.
|
float |
getInkSpreading()
Gets the amount of ink spreading.
|
float |
getN()
Gets the bar multiplier for wide bars.
|
float |
getSize()
Gets the size of the text.
|
int |
getTextAlignment()
Gets the text alignment.
|
float |
getX()
Gets the minimum bar width.
|
boolean |
isChecksumText()
Gets the property to show the generated checksum in the the text.
|
boolean |
isExtended()
Gets the property to generate extended barcode 39.
|
boolean |
isGenerateChecksum()
Gets the optional checksum generation.
|
boolean |
isGuardBars()
Gets the property to show the guard bars for barcode EAN.
|
boolean |
isStartStopText()
Sets the property to show the start and stop character '*' in the text for the barcode 39.
|
abstract Rectangle |
placeBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
Places the barcode in a PdfContentByte .
|
void |
setAltText(String altText)
Sets the alternate text.
|
void |
setBarHeight(float barHeight)
Sets the height of the bars.
|
void |
setBaseline(float baseline)
Sets the text baseline.
|
void |
setChecksumText(boolean checksumText)
Sets the property to show the generated checksum in the the text.
|
void |
setCode(String code)
Sets the code to generate.
|
void |
setCodeType(int codeType)
Sets the code type.
|
void |
setExtended(boolean extended)
Sets the property to generate extended barcode 39.
|
void |
setFont(BaseFont font)
Sets the text font.
|
void |
setGenerateChecksum(boolean generateChecksum)
Setter for property generateChecksum.
|
void |
setGuardBars(boolean guardBars)
Sets the property to show the guard bars for barcode EAN.
|
void |
setInkSpreading(float inkSpreading)
Sets the amount of ink spreading.
|
void |
setN(float n)
Sets the bar multiplier for wide bars.
|
void |
setSize(float size)
Sets the size of the text.
|
void |
setStartStopText(boolean startStopText)
Gets the property to show the start and stop character '*' in the text for the barcode 39.
|
void |
setTextAlignment(int textAlignment)
Sets the text alignment.
|
void |
setX(float x)
Sets the minimum bar width.
|
public static final int EAN13
public static final int EAN8
public static final int UPCA
public static final int UPCE
public static final int SUPP2
public static final int SUPP5
public static final int POSTNET
public static final int PLANET
public static final int CODE128
public static final int CODE128_UCC
public static final int CODE128_RAW
public static final int CODABAR
protected float x
protected float n
protected BaseFont font
null
if no text.
protected float size
protected float baseline
protected float barHeight
protected int textAlignment
Element.ALIGN_LEFT
, Element.ALIGN_CENTER
or Element.ALIGN_RIGHT
.
protected boolean generateChecksum
protected boolean checksumText
protected boolean startStopText
protected boolean extended
protected String code
protected boolean guardBars
protected int codeType
protected float inkSpreading
protected String altText
public float getX()
public void setX(float x)
x
- the minimum bar width
public float getN()
public void setN(float n)
n
- the bar multiplier for wide bars
public BaseFont getFont()
null
if no text.
null
if no text
public void setFont(BaseFont font)
font
- the text font. Set to null
to suppress any text
public float getSize()
public void setSize(float size)
size
- the size of the text
public float getBaseline()
public void setBaseline(float baseline)
baseline
- the baseline.
public float getBarHeight()
public void setBarHeight(float barHeight)
barHeight
- the height of the bars
public int getTextAlignment()
Element.ALIGN_LEFT
, Element.ALIGN_CENTER
or Element.ALIGN_RIGHT
.
public void setTextAlignment(int textAlignment)
Element.ALIGN_LEFT
, Element.ALIGN_CENTER
or Element.ALIGN_RIGHT
.
textAlignment
- the text alignment
public boolean isGenerateChecksum()
public void setGenerateChecksum(boolean generateChecksum)
generateChecksum
- New value of property generateChecksum.
public boolean isChecksumText()
public void setChecksumText(boolean checksumText)
checksumText
- new value of property checksumText
public boolean isStartStopText()
public void setStartStopText(boolean startStopText)
startStopText
- new value of property startStopText
public boolean isExtended()
public void setExtended(boolean extended)
extended
- new value of property extended
public String getCode()
public void setCode(String code)
code
- the code to generate
public boolean isGuardBars()
public void setGuardBars(boolean guardBars)
guardBars
- new value of property guardBars
public int getCodeType()
public void setCodeType(int codeType)
codeType
- the code type
public abstract Rectangle getBarcodeSize()
public abstract Rectangle placeBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
PdfContentByte
. 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:
|
|
Result |
---|---|---|
|
|
bars and text painted with current fill color |
|
|
bars and text painted with |
|
|
bars painted with current color |
|
|
bars painted with |
cb
- the PdfContentByte
where the barcode will be placed
barColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
public PdfTemplate createTemplateWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
cb
- the PdfContentByte
to create the template. It serves no other use
barColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
placeBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
public Image createImageWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
Image
with the barcode.
cb
- the PdfContentByte
to create the Image
. It serves no other use
barColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
Image
placeBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
public float getInkSpreading()
public void setInkSpreading(float inkSpreading)
inkSpreading
- the ink spreading
public String getAltText()
public void setAltText(String altText)
altText
- the alternate text
Copyright © 1998–2016. All rights reserved.