Class PDF417
java.lang.Object
com.google.zxing.pdf417.encoder.PDF417
Top-level class for the logic part of the PDF417 implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BarcodeMatrixprivate static final int[][]The codeword table from the Annex A of ISO/IEC 15438:2001(E).private booleanprivate Compactionprivate static final floatprivate Charsetprivate static final floatprivate intprivate intprivate intprivate intprivate static final floatprivate static final intThe start pattern (17 bits)private static final intThe stop pattern (18 bits) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intcalculateNumberOfRows(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 voidencodeChar(int pattern, int len, BarcodeRow logic) private voidencodeLowLevel(CharSequence fullCodewords, int c, int r, int errorCorrectionLevel, BarcodeMatrix logic) voidgenerateBarcodeLogic(String msg, int errorCorrectionLevel) voidgenerateBarcodeLogic(String msg, int errorCorrectionLevel, boolean autoECI) private static intgetNumberOfPadCodewords(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).voidsetCompact(boolean compact) voidsetCompaction(Compaction compaction) voidsetDimensions(int maxCols, int minCols, int maxRows, int minRows) Sets max/min row/col valuesvoidsetEncoding(Charset encoding)
-
Field Details
-
START_PATTERN
private static final int START_PATTERNThe start pattern (17 bits)- See Also:
-
STOP_PATTERN
private static final int STOP_PATTERNThe stop pattern (18 bits)- See Also:
-
CODEWORD_TABLE
private static final int[][] CODEWORD_TABLEThe codeword table from the Annex A of ISO/IEC 15438:2001(E). -
PREFERRED_RATIO
private static final float PREFERRED_RATIO- See Also:
-
DEFAULT_MODULE_WIDTH
private static final float DEFAULT_MODULE_WIDTH- See Also:
-
HEIGHT
private static final float HEIGHT- See Also:
-
barcodeMatrix
-
compact
private boolean compact -
compaction
-
encoding
-
minCols
private int minCols -
maxCols
private int maxCols -
maxRows
private int maxRows -
minRows
private int minRows
-
-
Constructor Details
-
PDF417
public PDF417() -
PDF417
public PDF417(boolean compact)
-
-
Method Details
-
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
-
encodeLowLevel
private void encodeLowLevel(CharSequence fullCodewords, int c, int r, int errorCorrectionLevel, BarcodeMatrix logic) -
generateBarcodeLogic
- 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(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
- Parameters:
compaction- compaction mode to use
-
setCompact
public void setCompact(boolean compact) - Parameters:
compact- if true, enables compaction
-
setEncoding
- Parameters:
encoding- sets character encoding to use
-