Package com.itextpdf.barcodes
Class BarcodePDF417
java.lang.Object
com.itextpdf.barcodes.Barcode2D
com.itextpdf.barcodes.BarcodePDF417
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
protected static final int
protected static final int
protected static final int
protected int
protected static final int
protected static final int
protected static final int
protected int
protected static final float
protected static final float
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
static final int
The error level correction is set automatically according to ISO 15438 recommendations.static final int
The size will be at leastcodeColumns
with a variable number ofcodeRows
.static final int
The size of the barcode will be at leastcodeColumns*codeRows
.static final int
The size will be at leastcodeRows
with a variable number ofcodeColumns
.static final int
One single binary segment is usedstatic final int
Inverts the output bits of the raw bitmap that is normally bit one for black.static final int
Auto-size is made based onaspectRatio
andyHeight
.static final int
The error level correction is set by the user.static final int
Use Macro PDF417 Encodingstatic final int
Notext
interpretation is done and the content ofcodewords
is used directly.protected static final int
protected static final int
protected static final int
protected BarcodePDF417.SegmentList
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
Fields inherited from class com.itextpdf.barcodes.Barcode2D
DEFAULT_MODULE_SIZE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
assemble()
protected void
basicNumberCompaction
(int start, int length) protected void
byteCompaction6
(int start) protected void
calculateErrorCorrection
(int dest) protected boolean
checkSegmentType
(BarcodePDF417.Segment segment, char type) createAwtImage
(Color foreground, Color background) Creates ajava.awt.Image
.createFormXObject
(Color foreground, float moduleWidth, float moduleHeight, PdfDocument document) Creates a PdfFormXObject with the barcode with given module width and module height.createFormXObject
(Color foreground, PdfDocument document) Creates a PdfFormXObject with the barcode.protected void
dumpList()
float
Gets the barcode aspect ratio.Gets the maximum area that the barcode and the text, if any, will occupy.int
Gets the number of X pixels ofoutBits
.byte[]
getCode()
Gets the bytes that form the barcode.int
Gets the number of barcode data columns.int
Gets the number of Y pixels ofoutBits
.int[]
Gets the codeword array.int
Gets the error level correction used for the barcode.int
Gets the length of the codewords.protected int
int
Gets the options to generate the barcode.byte[]
Gets the raw image bits of the barcode.protected int
getSegmentLength
(BarcodePDF417.Segment segment) protected int
getTextTypeAndValue
(int maxLength, int idx) float
Gets the Y pixel height relative to X.protected static int
maxPossibleErrorLevel
(int remain) protected void
numberCompaction
(int start, int length) protected void
outCodeword
(int codeword) protected void
outCodeword17
(int codeword) protected void
outCodeword18
(int codeword) protected void
protected void
protected void
void
Paints the barcode.placeBarcode
(PdfCanvas canvas, Color foreground) Places the barcode in aPdfCanvas
.placeBarcode
(PdfCanvas canvas, Color foreground, float moduleWidth, float moduleHeight) void
setAspectRatio
(float aspectRatio) Sets the barcode aspect ratio.void
setCode
(byte[] code) Sets the bytes that form the barcode.void
Sets the code that will form the barcode.void
setCodeColumns
(int codeColumns) Sets the number of barcode data columns.void
setCodeRows
(int codeRows) Sets the number of barcode rows.void
Set the default settings that correspond toPDF417_USE_ASPECT_RATIO
andPDF417_AUTO_ERROR_LEVEL
.void
setErrorLevel
(int errorLevel) Sets the error level correction for the barcode.void
setLenCodewords
(int lenCodewords) Sets the length of the codewords.void
setMacroFileId
(String id) Sets the File ID for macro PDF417 encodingvoid
setMacroSegmentCount
(int cnt) Sets the segment count for macro PDF417 encodingvoid
setMacroSegmentId
(int id) Sets the segment id for macro PDF417 encodingvoid
setOptions
(int options) Sets the options to generate the barcode.void
setYHeight
(float yHeight) Sets the Y pixel height relative to X.protected void
textCompaction
(int start, int length) Methods inherited from class com.itextpdf.barcodes.Barcode2D
createFormXObject
-
Field Details
-
PDF417_USE_ASPECT_RATIO
public static final int PDF417_USE_ASPECT_RATIOAuto-size is made based onaspectRatio
andyHeight
.- See Also:
-
PDF417_FIXED_RECTANGLE
public static final int PDF417_FIXED_RECTANGLEThe size of the barcode will be at leastcodeColumns*codeRows
.- See Also:
-
PDF417_FIXED_COLUMNS
public static final int PDF417_FIXED_COLUMNSThe size will be at leastcodeColumns
with a variable number ofcodeRows
.- See Also:
-
PDF417_FIXED_ROWS
public static final int PDF417_FIXED_ROWSThe size will be at leastcodeRows
with a variable number ofcodeColumns
.- See Also:
-
PDF417_AUTO_ERROR_LEVEL
public static final int PDF417_AUTO_ERROR_LEVELThe error level correction is set automatically according to ISO 15438 recommendations.- See Also:
-
PDF417_USE_ERROR_LEVEL
public static final int PDF417_USE_ERROR_LEVELThe error level correction is set by the user. It can be 0 to 8.- See Also:
-
PDF417_FORCE_BINARY
public static final int PDF417_FORCE_BINARYOne single binary segment is used- See Also:
-
PDF417_USE_RAW_CODEWORDS
public static final int PDF417_USE_RAW_CODEWORDSNotext
interpretation is done and the content ofcodewords
is used directly.- See Also:
-
PDF417_INVERT_BITMAP
public static final int PDF417_INVERT_BITMAPInverts the output bits of the raw bitmap that is normally bit one for black. It has only effect for the raw bitmap.- See Also:
-
PDF417_USE_MACRO
public static final int PDF417_USE_MACROUse Macro PDF417 Encoding -
START_PATTERN
protected static final int START_PATTERN- See Also:
-
STOP_PATTERN
protected static final int STOP_PATTERN- See Also:
-
START_CODE_SIZE
protected static final int START_CODE_SIZE- See Also:
-
STOP_SIZE
protected static final int STOP_SIZE- See Also:
-
MOD
protected static final int MOD- See Also:
-
ALPHA
protected static final int ALPHA- See Also:
-
LOWER
protected static final int LOWER- See Also:
-
MIXED
protected static final int MIXED- See Also:
-
PUNCTUATION
protected static final int PUNCTUATION- See Also:
-
ISBYTE
protected static final int ISBYTE- See Also:
-
BYTESHIFT
protected static final int BYTESHIFT- See Also:
-
PL
protected static final int PL- See Also:
-
LL
protected static final int LL- See Also:
-
AS
protected static final int AS- See Also:
-
ML
protected static final int ML- See Also:
-
AL
protected static final int AL- See Also:
-
PS
protected static final int PS- See Also:
-
PAL
protected static final int PAL- See Also:
-
SPACE
protected static final int SPACE- See Also:
-
TEXT_MODE
protected static final int TEXT_MODE- See Also:
-
BYTE_MODE_6
protected static final int BYTE_MODE_6- See Also:
-
BYTE_MODE
protected static final int BYTE_MODE- See Also:
-
NUMERIC_MODE
protected static final int NUMERIC_MODE- See Also:
-
ABSOLUTE_MAX_TEXT_SIZE
protected static final int ABSOLUTE_MAX_TEXT_SIZE- See Also:
-
MAX_DATA_CODEWORDS
protected static final int MAX_DATA_CODEWORDS- See Also:
-
MACRO_SEGMENT_ID
protected static final int MACRO_SEGMENT_ID- See Also:
-
MACRO_LAST_SEGMENT
protected static final int MACRO_LAST_SEGMENT- See Also:
-
DEFAUL_MODULE_WIDTH
protected static final float DEFAUL_MODULE_WIDTH- See Also:
-
DEFAUL_MODULE_HEIGHT
protected static final float DEFAUL_MODULE_HEIGHT- See Also:
-
bitPtr
protected int bitPtr -
cwPtr
protected int cwPtr -
segmentList
-
-
Constructor Details
-
BarcodePDF417
public BarcodePDF417()Creates a newBarcodePDF417
with the default settings.
-
-
Method Details
-
setMacroSegmentId
public void setMacroSegmentId(int id) Sets the segment id for macro PDF417 encoding- Parameters:
-
id
- the id (starting at 0) - See Also:
-
setMacroSegmentCount
public void setMacroSegmentCount(int cnt) Sets the segment count for macro PDF417 encoding- Parameters:
-
cnt
- the number of macro segments - See Also:
-
setMacroFileId
Sets the File ID for macro PDF417 encoding- Parameters:
-
id
- the file id
-
setDefaultParameters
public void setDefaultParameters()Set the default settings that correspond toPDF417_USE_ASPECT_RATIO
andPDF417_AUTO_ERROR_LEVEL
. -
getBarcodeSize
Description copied from class:Barcode2D
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 classBarcode2D
- Returns:
- the size the barcode occupies.
-
placeBarcode
Description copied from class:Barcode2D
Places the barcode in aPdfCanvas
. The barcode is always placed at coordinates (0, 0). Use the translation matrix to move it elsewhere.- Specified by:
-
placeBarcode
in classBarcode2D
- Parameters:
-
canvas
- thePdfCanvas
where the barcode will be placed -
foreground
- the foreground color. It can benull
- Returns:
- the dimensions the barcode occupies
-
placeBarcode
-
paintCode
public void paintCode()Paints the barcode. If no exception was thrown a valid barcode is available. -
createFormXObject
Creates a PdfFormXObject with the barcode.- Specified by:
-
createFormXObject
in classBarcode2D
- Parameters:
-
foreground
- the color of the pixels. It can benull
-
document
- The document - Returns:
- the XObject.
-
createFormXObject
public PdfFormXObject createFormXObject(Color foreground, float moduleWidth, float moduleHeight, PdfDocument document) Creates a PdfFormXObject with the barcode with given module width and module height.- Parameters:
-
foreground
- The color of the pixels. It can benull
-
moduleWidth
- The width of the pixels. -
moduleHeight
- The height of the pixels. -
document
- The document - Returns:
- the XObject.
-
createAwtImage
Creates ajava.awt.Image
.- Parameters:
-
foreground
- the color of the bars -
background
- the color of the background - Returns:
- the image
-
getOutBits
public byte[] getOutBits()Gets the raw image bits of the barcode. The image will have to be scaled in the Y direction byyHeight
.- Returns:
- The raw barcode image
-
getBitColumns
public int getBitColumns()Gets the number of X pixels ofoutBits
.- Returns:
-
the number of X pixels of
outBits
-
getCodeRows
public int getCodeRows()Gets the number of Y pixels ofoutBits
. It is also the number of rows in the barcode.- Returns:
-
the number of Y pixels of
outBits
-
setCodeRows
public void setCodeRows(int codeRows) Sets the number of barcode rows. This number may be changed to keep the barcode valid.- Parameters:
-
codeRows
- the number of barcode rows
-
getCodeColumns
public int getCodeColumns()Gets the number of barcode data columns.- Returns:
- he number of barcode data columns
-
setCodeColumns
public void setCodeColumns(int codeColumns) Sets the number of barcode data columns. This number may be changed to keep the barcode valid.- Parameters:
-
codeColumns
- the number of barcode data columns
-
getCodewords
public int[] getCodewords()Gets the codeword array. This array is always 928 elements long. It can be written to if the optionPDF417_USE_RAW_CODEWORDS
is set.- Returns:
- the codeword array
-
getLenCodewords
public int getLenCodewords()Gets the length of the codewords.- Returns:
- the length of the codewords
-
setLenCodewords
public void setLenCodewords(int lenCodewords) Sets the length of the codewords.- Parameters:
-
lenCodewords
- the length of the codewords
-
getErrorLevel
public int getErrorLevel()Gets the error level correction used for the barcode. It may different from the previously set value.- Returns:
- the error level correction used for the barcode
-
setErrorLevel
public void setErrorLevel(int errorLevel) Sets the error level correction for the barcode.- Parameters:
-
errorLevel
- the error level correction for the barcode
-
getCode
public byte[] getCode()Gets the bytes that form the barcode. This bytes should be interpreted in the codepage Cp437.- Returns:
- the bytes that form the barcode
-
setCode
public void setCode(byte[] code) Sets the bytes that form the barcode. This bytes should be interpreted in the codepage Cp437.- Parameters:
-
code
- the bytes that form the barcode
-
setCode
Sets the code that will form the barcode. This text is converted to bytes using the encoding Cp437.- Parameters:
-
text
- the text that will form the barcode
-
getOptions
public int getOptions()Gets the options to generate the barcode.- Returns:
- the options to generate the barcode
-
setOptions
public void setOptions(int options) Sets the options to generate the barcode. This can be all thePDF417_*
constants.- Parameters:
-
options
- the options to generate the barcode
-
getAspectRatio
public float getAspectRatio()Gets the barcode aspect ratio.- Returns:
- the barcode aspect ratio
-
setAspectRatio
public void setAspectRatio(float aspectRatio) Sets the barcode aspect ratio. A ratio or 0.5 will make the barcode width twice as large as the height.- Parameters:
-
aspectRatio
- the barcode aspect ratio
-
getYHeight
public float getYHeight()Gets the Y pixel height relative to X.- Returns:
- the Y pixel height relative to X
-
setYHeight
public void setYHeight(float yHeight) Sets the Y pixel height relative to X. It is usually 3.- Parameters:
-
yHeight
- the Y pixel height relative to X
-
outCodeword17
protected void outCodeword17(int codeword) -
outCodeword18
protected void outCodeword18(int codeword) -
outCodeword
protected void outCodeword(int codeword) -
outStopPattern
protected void outStopPattern() -
outStartPattern
protected void outStartPattern() -
outPaintCode
protected void outPaintCode() -
calculateErrorCorrection
protected void calculateErrorCorrection(int dest) -
textCompaction
protected void textCompaction(int start, int length) -
basicNumberCompaction
protected void basicNumberCompaction(int start, int length) -
getTextTypeAndValue
protected int getTextTypeAndValue(int maxLength, int idx) -
checkSegmentType
-
getSegmentLength
-
numberCompaction
protected void numberCompaction(int start, int length) -
byteCompaction6
protected void byteCompaction6(int start) -
assemble
protected void assemble() -
maxPossibleErrorLevel
protected static int maxPossibleErrorLevel(int remain) -
dumpList
protected void dumpList() -
getMaxSquare
protected int getMaxSquare()
-