Package com.google.zxing.pdf417.encoder
Class PDF417
- java.lang.Object
-
- com.google.zxing.pdf417.encoder.PDF417
-
public final class PDF417 extends java.lang.Object
Top-level class for the logic part of the PDF417 implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private BarcodeMatrix
barcodeMatrix
private static int[][]
CODEWORD_TABLE
The codeword table from the Annex A of ISO/IEC 15438:2001(E).private boolean
compact
private Compaction
compaction
private static float
DEFAULT_MODULE_WIDTH
private java.nio.charset.Charset
encoding
private static float
HEIGHT
private int
maxCols
private int
maxRows
private int
minCols
private int
minRows
private static float
PREFERRED_RATIO
private static int
START_PATTERN
The start pattern (17 bits)private static int
STOP_PATTERN
The stop pattern (18 bits)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
calculateNumberOfRows(int m, int k, int c)
Calculates the necessary number of rows as described in annex Q of ISO/IEC 15438:2001(E).private int[]
determineDimensions(int sourceCodeWords, int errorCorrectionCodeWords)
Determine optimal nr of columns and rows for the specified number of codewords.private static void
encodeChar(int pattern, int len, BarcodeRow logic)
private void
encodeLowLevel(java.lang.CharSequence fullCodewords, int c, int r, int errorCorrectionLevel, BarcodeMatrix logic)
void
generateBarcodeLogic(java.lang.String msg, int errorCorrectionLevel)
void
generateBarcodeLogic(java.lang.String msg, int errorCorrectionLevel, boolean autoECI)
BarcodeMatrix
getBarcodeMatrix()
private static int
getNumberOfPadCodewords(int m, int k, int c, int r)
Calculates the number of pad codewords as described in 4.9.2 of ISO/IEC 15438:2001(E).void
setCompact(boolean compact)
void
setCompaction(Compaction compaction)
void
setDimensions(int maxCols, int minCols, int maxRows, int minRows)
Sets max/min row/col valuesvoid
setEncoding(java.nio.charset.Charset encoding)
-
-
-
Field Detail
-
START_PATTERN
private static final int START_PATTERN
The start pattern (17 bits)- See Also:
- Constant Field Values
-
STOP_PATTERN
private static final int STOP_PATTERN
The stop pattern (18 bits)- See Also:
- Constant Field Values
-
CODEWORD_TABLE
private static final int[][] CODEWORD_TABLE
The codeword table from the Annex A of ISO/IEC 15438:2001(E).
-
PREFERRED_RATIO
private static final float PREFERRED_RATIO
- See Also:
- Constant Field Values
-
DEFAULT_MODULE_WIDTH
private static final float DEFAULT_MODULE_WIDTH
- See Also:
- Constant Field Values
-
HEIGHT
private static final float HEIGHT
- See Also:
- Constant Field Values
-
barcodeMatrix
private BarcodeMatrix barcodeMatrix
-
compact
private boolean compact
-
compaction
private Compaction compaction
-
encoding
private java.nio.charset.Charset encoding
-
minCols
private int minCols
-
maxCols
private int maxCols
-
maxRows
private int maxRows
-
minRows
private int minRows
-
-
Method Detail
-
getBarcodeMatrix
public BarcodeMatrix getBarcodeMatrix()
-
calculateNumberOfRows
private static int calculateNumberOfRows(int m, int k, int c)
Calculates the necessary number of rows as described in annex Q of ISO/IEC 15438:2001(E).- Parameters:
m
- the number of source codewords prior to the additional of the Symbol Length Descriptor and any pad codewordsk
- the number of error correction codewordsc
- the number of columns in the symbol in the data region (excluding start, stop and row indicator codewords)- Returns:
- the number of rows in the symbol (r)
-
getNumberOfPadCodewords
private static int getNumberOfPadCodewords(int m, int k, int c, int r)
Calculates the number of pad codewords as described in 4.9.2 of ISO/IEC 15438:2001(E).- Parameters:
m
- the number of source codewords prior to the additional of the Symbol Length Descriptor and any pad codewordsk
- the number of error correction codewordsc
- the number of columns in the symbol in the data region (excluding start, stop and row indicator codewords)r
- the number of rows in the symbol- Returns:
- the number of pad codewords
-
encodeChar
private static void encodeChar(int pattern, int len, BarcodeRow logic)
-
encodeLowLevel
private void encodeLowLevel(java.lang.CharSequence fullCodewords, int c, int r, int errorCorrectionLevel, BarcodeMatrix logic)
-
generateBarcodeLogic
public void generateBarcodeLogic(java.lang.String msg, int errorCorrectionLevel) throws WriterException
- Parameters:
msg
- message to encodeerrorCorrectionLevel
- PDF417 error correction level to use- Throws:
WriterException
- if the contents cannot be encoded in this format
-
generateBarcodeLogic
public void generateBarcodeLogic(java.lang.String msg, int errorCorrectionLevel, boolean autoECI) throws WriterException
- Parameters:
msg
- message to encodeerrorCorrectionLevel
- PDF417 error correction level to useautoECI
- automatically insert ECIs if needed- Throws:
WriterException
- if the contents cannot be encoded in this format
-
determineDimensions
private int[] determineDimensions(int sourceCodeWords, int errorCorrectionCodeWords) throws WriterException
Determine optimal nr of columns and rows for the specified number of codewords.- Parameters:
sourceCodeWords
- number of code wordserrorCorrectionCodeWords
- number of error correction code words- Returns:
- dimension object containing cols as width and rows as height
- Throws:
WriterException
-
setDimensions
public void setDimensions(int maxCols, int minCols, int maxRows, int minRows)
Sets max/min row/col values- Parameters:
maxCols
- maximum allowed columnsminCols
- minimum allowed columnsmaxRows
- maximum allowed rowsminRows
- minimum allowed rows
-
setCompaction
public void setCompaction(Compaction compaction)
- Parameters:
compaction
- compaction mode to use
-
setCompact
public void setCompact(boolean compact)
- Parameters:
compact
- if true, enables compaction
-
setEncoding
public void setEncoding(java.nio.charset.Charset encoding)
- Parameters:
encoding
- sets character encoding to use
-
-