public abstract class Barcode1D extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_CENTER |
static int |
ALIGN_LEFT |
static int |
ALIGN_RIGHT |
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.
|
protected String |
code
The code to generate.
|
protected int |
codeType
The code type.
|
protected Color |
DEFAULT_BAR_BACKGROUND_COLOR
The default color to draw if a bar is not present.
|
protected Color |
DEFAULT_BAR_FOREGROUND_COLOR
The default color to draw if a bar is present.
|
protected PdfDocument |
document |
protected boolean |
extended
Generates extended barcode 39.
|
protected PdfFont |
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.
|
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.
|
protected int |
textAlignment
The text alignment.
|
protected float |
x
The minimum bar width.
|
Modifier | Constructor and Description |
---|---|
protected |
Barcode1D(PdfDocument document) |
Modifier and Type | Method and Description |
---|---|
abstract Image |
createAwtImage(Color foreground, Color background)
Creates a java.awt.Image .
|
PdfFormXObject |
createFormXObject(Color barColor, Color textColor, PdfDocument document)
Creates a PdfFormXObject with the barcode.
|
PdfFormXObject |
createFormXObject(PdfDocument document)
Creates a PdfFormXObject with the barcode.
|
void |
fitWidth(float width)
Make the barcode occupy the specified width.
|
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.
|
protected float |
getDescender() |
PdfFont |
getFont()
Gets the text font.
|
float |
getInkSpreading()
Gets the amount of ink spreading.
|
float |
getN()
Gets the bar multiplier for wide bars.
|
float |
getSize() |
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(PdfCanvas canvas, Color barColor, Color textColor)
Places the barcode in a PdfCanvas .
|
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(PdfFont 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 ALIGN_LEFT
public static final int ALIGN_RIGHT
public static final int ALIGN_CENTER
protected final Color DEFAULT_BAR_FOREGROUND_COLOR
protected final Color DEFAULT_BAR_BACKGROUND_COLOR
protected PdfDocument document
protected float x
protected float n
protected PdfFont font
null
if no text.
protected float size
protected float baseline
protected float barHeight
protected int textAlignment
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
protected Barcode1D(PdfDocument document)
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 PdfFont getFont()
null
if no text.
null
if no text
public void setFont(PdfFont 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()
public void setTextAlignment(int textAlignment)
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(PdfCanvas canvas, Color barColor, Color textColor)
PdfCanvas
. 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 with textColor |
barColor |
textColor |
bars painted with barColor text painted with textColor |
canvas
- the PdfCanvas
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 float getInkSpreading()
public void setInkSpreading(float inkSpreading)
inkSpreading
- the ink spreading
public String getAltText()
public void setAltText(String altText)
altText
- the alternate text
public abstract Image createAwtImage(Color foreground, Color background)
java.awt.Image
. This image only contains the bars without any text.
foreground
- the color of the bars. If null
defaults to DEFAULT_BAR_FOREGROUND_COLOR
background
- the color of the background. If null
defaults to DEFAULT_BAR_BACKGROUND_COLOR
public PdfFormXObject createFormXObject(PdfDocument document)
document
- The document
createFormXObject(Color, Color, PdfDocument)
public PdfFormXObject createFormXObject(Color barColor, Color textColor, PdfDocument document)
barColor
- The color of the bars. It can be null
textColor
- The color of the text. It can be null
document
- The document
placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
public void fitWidth(float width)
width
- The width
protected float getDescender()
Copyright © 1998–2020 iText Group NV. All rights reserved.