Package com.itextpdf.barcodes
Class BarcodeQRCode
java.lang.Object
com.itextpdf.barcodes.Barcode2D
com.itextpdf.barcodes.BarcodeQRCode
A QRCode implementation based on the zxing code.
-
Field Summary
Fields inherited from class com.itextpdf.barcodes.Barcode2D
DEFAULT_MODULE_SIZE
-
Constructor Summary
ConstructorDescriptionBarcodeQRCode
(String content) Creates the QR barcode with default error correction level (ErrorCorrectionLevel.L) and default character set (ISO-8859-1).BarcodeQRCode
(String code, Map<EncodeHintType, Object> hints) Creates the QR barcode. -
Method Summary
Modifier and TypeMethodDescriptioncreateAwtImage
(Color foreground, Color background) Creates ajava.awt.Image
.createFormXObject
(Color foreground, float moduleSize, PdfDocument document) Creates a PdfFormXObject with the barcode.createFormXObject
(Color foreground, PdfDocument document) Creates a PdfFormXObject with the barcode.Gets the size of the barcode gridgetBarcodeSize
(float moduleSize) Gets the barcode sizegetCode()
Gets the current data.getHints()
placeBarcode
(PdfCanvas canvas, Color foreground) Places the barcode in aPdfCanvas
.placeBarcode
(PdfCanvas canvas, Color foreground, float moduleSide) * Places the barcode in aPdfCanvas
.void
Regenerates barcode after changes in hints or code.void
Sets the data to be encoded by the barcode.void
setHints
(Map<EncodeHintType, Object> hints) Methods inherited from class com.itextpdf.barcodes.Barcode2D
createFormXObject
-
Constructor Details
-
BarcodeQRCode
Creates the QR barcode.- Parameters:
-
code
- the text to be encoded -
hints
- barcode hints. See #setHints for description.
-
BarcodeQRCode
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()
-
-
Method Details
-
getCode
Gets the current data.- Returns:
- the encoded data
-
setCode
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
- Returns:
- modifiers to change the way the barcode is created.
-
setHints
- 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
Gets the size of the barcode grid- Specified by:
-
getBarcodeSize
in classBarcode2D
- Returns:
- the size the barcode occupies.
-
getBarcodeSize
Gets the barcode size- Parameters:
-
moduleSize
- The module size - Returns:
- The size of the barcode
-
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
* Places the barcode in aPdfCanvas
. The barcode is always placed at coordinates (0, 0). Use the translation matrix to move it elsewhere.- Parameters:
-
canvas
- thePdfCanvas
where the barcode will be placed -
foreground
- the foreground color. It can benull
-
moduleSide
- the size of the square grid cell - Returns:
- the dimensions the barcode occupies
-
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
Creates a PdfFormXObject with the barcode.- Parameters:
-
foreground
- The color of the pixels. It can benull
-
moduleSize
- The size 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
-