Package com.itextpdf.text.pdf
Class BarcodeQRCode
- java.lang.Object
-
- com.itextpdf.text.pdf.BarcodeQRCode
-
public class BarcodeQRCode extends java.lang.Object
A QRCode implementation based on the zxing code.- Since:
- 5.0.2
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ByteMatrix
bm
-
Constructor Summary
Constructors Constructor Description BarcodeQRCode(java.lang.String content, int width, int height, java.util.Map<EncodeHintType,java.lang.Object> hints)
Creates the QR barcode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Image
createAwtImage(java.awt.Color foreground, java.awt.Color background)
Creates ajava.awt.Image
.Rectangle
getBarcodeSize()
Gets the size of the barcode grid.private byte[]
getBitMatrix()
Image
getImage()
Gets anImage
with the barcode.void
placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleSide)
-
-
-
Field Detail
-
bm
ByteMatrix bm
-
-
Constructor Detail
-
BarcodeQRCode
public BarcodeQRCode(java.lang.String content, int width, int height, java.util.Map<EncodeHintType,java.lang.Object> hints)
Creates the QR barcode. The barcode is always created with the smallest possible size and is then stretched to the width and height given. Set the width and height to 1 to get an unscaled barcode.- Parameters:
content
- the text to be encodedwidth
- the barcode widthheight
- the barcode heighthints
- modifiers to change the way the barcode is create. 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.- Throws:
WriterException
-
-
Method Detail
-
getBitMatrix
private byte[] getBitMatrix()
-
getImage
public Image getImage() throws BadElementException
Gets anImage
with the barcode.- Returns:
- the barcode
Image
- Throws:
BadElementException
- on error
-
createAwtImage
public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background)
Creates ajava.awt.Image
.- Parameters:
foreground
- the color of the barsbackground
- the color of the background- Returns:
- the image
-
placeBarcode
public void placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleSide)
-
getBarcodeSize
public Rectangle getBarcodeSize()
Gets the size of the barcode grid.
-
-