Class BarcodeQRCode


  • public class BarcodeQRCode
    extends Barcode2D
    A QRCode implementation based on the zxing code.
    • Field Detail

      • hints

        java.util.Map<EncodeHintType,​java.lang.Object> hints
        modifiers to change the way the barcode is create.
      • code

        java.lang.String code
    • Constructor Detail

      • BarcodeQRCode

        public BarcodeQRCode​(java.lang.String code,
                             java.util.Map<EncodeHintType,​java.lang.Object> hints)
        Creates the QR barcode.
        Parameters:
        code - the text to be encoded
        hints - barcode hints. See #setHints for description.
      • BarcodeQRCode

        public BarcodeQRCode​(java.lang.String content)
        Creates the QR barcode with default error correction level (ErrorCorrectionLevel.L) and default character set (ISO-8859-1).
        Parameters:
        content - the text to be encoded
      • BarcodeQRCode

        public BarcodeQRCode()
        Creates an instance of the BarcodeQRCode class.
    • Method Detail

      • getCode

        public java.lang.String getCode()
        Gets the current data.
        Returns:
        the encoded data
      • setCode

        public void setCode​(java.lang.String code)
        Sets the data to be encoded by the barcode. If not specified in hints otherwise, the character set should be ISO-8859-1.
        Parameters:
        code - The data to encode
      • getHints

        public java.util.Map<EncodeHintType,​java.lang.Object> getHints()
        Returns:
        modifiers to change the way the barcode is created.
      • setHints

        public void setHints​(java.util.Map<EncodeHintType,​java.lang.Object> hints)
        Parameters:
        hints - modifiers to change the way the barcode is created. They can be EncodeHintType.ERROR_CORRECTION and EncodeHintType.CHARACTER_SET. For EncodeHintType.ERROR_CORRECTION the values can be ErrorCorrectionLevel.L, M, Q, H. For EncodeHintType.CHARACTER_SET the values are strings and can be Cp437, Shift_JIS and ISO-8859-1 to ISO-8859-16. You can also use UTF-8, but correct behaviour is not guaranteed as Unicode is not supported in QRCodes. The default value is ISO-8859-1.
      • regenerate

        public void regenerate()
        Regenerates barcode after changes in hints or code.
      • getBarcodeSize

        public Rectangle getBarcodeSize()
        Gets the size of the barcode grid
        Specified by:
        getBarcodeSize in class Barcode2D
        Returns:
        the size the barcode occupies.
      • getBarcodeSize

        public Rectangle getBarcodeSize​(float moduleSize)
        Gets the barcode size
        Parameters:
        moduleSize - The module size
        Returns:
        The size of the barcode
      • placeBarcode

        public Rectangle placeBarcode​(PdfCanvas canvas,
                                      Color foreground)
        Description copied from class: Barcode2D
        Places the barcode in a PdfCanvas. The barcode is always placed at coordinates (0, 0). Use the translation matrix to move it elsewhere.
        Specified by:
        placeBarcode in class Barcode2D
        Parameters:
        canvas - the PdfCanvas where the barcode will be placed
        foreground - the foreground color. It can be null
        Returns:
        the dimensions the barcode occupies
      • placeBarcode

        public Rectangle placeBarcode​(PdfCanvas canvas,
                                      Color foreground,
                                      float moduleSide)
        * Places the barcode in a PdfCanvas. The barcode is always placed at coordinates (0, 0). Use the translation matrix to move it elsewhere.
        Parameters:
        canvas - the PdfCanvas where the barcode will be placed
        foreground - the foreground color. It can be null
        moduleSide - the size of the square grid cell
        Returns:
        the dimensions the barcode occupies
      • createFormXObject

        public PdfFormXObject createFormXObject​(Color foreground,
                                                PdfDocument document)
        Creates a PdfFormXObject with the barcode.
        Specified by:
        createFormXObject in class Barcode2D
        Parameters:
        foreground - the color of the pixels. It can be null
        document - The document
        Returns:
        the XObject.
      • createFormXObject

        public PdfFormXObject createFormXObject​(Color foreground,
                                                float moduleSize,
                                                PdfDocument document)
        Creates a PdfFormXObject with the barcode.
        Parameters:
        foreground - The color of the pixels. It can be null
        moduleSize - The size of the pixels.
        document - The document
        Returns:
        the XObject.
      • createAwtImage

        public java.awt.Image createAwtImage​(java.awt.Color foreground,
                                             java.awt.Color background)
        Creates a java.awt.Image.
        Parameters:
        foreground - the color of the bars
        background - the color of the background
        Returns:
        the image
      • getBitMatrix

        private byte[] getBitMatrix()