Class PDF417


  • public final class PDF417
    extends java.lang.Object
    Top-level class for the logic part of the PDF417 implementation.
    • 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).
      • compact

        private boolean compact
      • encoding

        private java.nio.charset.Charset encoding
      • minCols

        private int minCols
      • maxCols

        private int maxCols
      • maxRows

        private int maxRows
      • minRows

        private int minRows
    • Constructor Detail

      • PDF417

        public PDF417()
      • PDF417

        public PDF417​(boolean compact)
    • Method Detail

      • 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 codewords
        k - the number of error correction codewords
        c - 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 codewords
        k - the number of error correction codewords
        c - 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 encode
        errorCorrectionLevel - 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 encode
        errorCorrectionLevel - PDF417 error correction level to use
        autoECI - 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 words
        errorCorrectionCodeWords - 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 columns
        minCols - minimum allowed columns
        maxRows - maximum allowed rows
        minRows - 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