Class BarcodeQRCode
java.lang.Object
com.itextpdf.barcodes.Barcode2D
com.itextpdf.barcodes.BarcodeQRCode
A QRCode implementation based on the zxing code.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ByteMatrix(package private) String(package private) Map<EncodeHintType, Object> modifiers to change the way the barcode is create.Fields inherited from class Barcode2D
DEFAULT_MODULE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance of theBarcodeQRCodeclass.BarcodeQRCode(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 sizeprivate byte[]getCode()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.voidRegenerates barcode after changes in hints or code.voidSets the data to be encoded by the barcode.voidsetHints(Map<EncodeHintType, Object> hints) Methods inherited from class Barcode2D
createFormXObject
-
Field Details
-
bm
ByteMatrix bm -
hints
Map<EncodeHintType, Object> hintsmodifiers to change the way the barcode is create. -
code
String code
-
-
Constructor Details
-
BarcodeQRCode
Creates the QR barcode.- Parameters:
code- the text to be encodedhints- 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()Creates an instance of theBarcodeQRCodeclass.
-
-
Method Details
-
getCode
-
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:
getBarcodeSizein 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:Barcode2DPlaces the barcode in aPdfCanvas. The barcode is always placed at coordinates (0, 0). Use the translation matrix to move it elsewhere.- Specified by:
placeBarcodein classBarcode2D- Parameters:
canvas- thePdfCanvaswhere the barcode will be placedforeground- 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- thePdfCanvaswhere the barcode will be placedforeground- the foreground color. It can benullmoduleSide- the size of the square grid cell- Returns:
- the dimensions the barcode occupies
-
createFormXObject
Creates a PdfFormXObject with the barcode.- Specified by:
createFormXObjectin classBarcode2D- Parameters:
foreground- the color of the pixels. It can benulldocument- The document- Returns:
- the XObject.
-
createFormXObject
Creates a PdfFormXObject with the barcode.- Parameters:
foreground- The color of the pixels. It can benullmoduleSize- The size of the pixels.document- The document- Returns:
- the XObject.
-
createAwtImage
-
getBitMatrix
private byte[] getBitMatrix()
-