Package com.itextpdf.barcodes.qrcode
Class QRCode
java.lang.Object
com.itextpdf.barcodes.qrcode.QRCode
A QR code (short for "quick-response code") is a type of two-dimensional matrix barcode, invented in 1994, by
Japanese company Denso Wave for labelling automobile parts.[1][2] A barcode is a machine-readable optical image that
contains information specific to the labelled item. In practice, QR codes contain data for a locator, an identifier,
and web tracking. To efficiently store data, QR codes use four standardized modes of encoding (i) numeric, (ii)
alphanumeric, (iii) byte or binary, and (iv) kanji.[3]
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ErrorCorrectionLevel
private int
private ByteMatrix
private int
private Mode
static final int
private int
private int
private int
private int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
at
(int x, int y) Retrieve the value of the module (cell) pointed by "x" and "y" in the matrix of the QR Code.Possible error correction level values ranked from lowest error correction capability to highest: L, M, Q, Hint
int
getMode()
Mode used by the QR code to encode data into bits.int
int
int
int
int
Together with error correction level, the version determines the information capacity of the QR code.boolean
isValid()
Check the validity of all member variablesstatic boolean
isValidMaskPattern
(int maskPattern) Check if "mask_pattern" is valid.void
setECLevel
(ErrorCorrectionLevel value) Set the error correction level of th QR code.void
setMaskPattern
(int value) Set the masking patternvoid
setMatrix
(ByteMatrix value) Set the byte-matrixvoid
setMatrixWidth
(int value) Sets the width of the byte matrixvoid
Set the data encoding mode of the QR code Possible modes: TERMINATOR, NUMERIC, ALPHANUMERIC, STRUCTURED_APPEND, BYTE, ECI, KANJI, FNC1_FIRST_POSITION, FNC2_SECOND_POSITIONvoid
setNumDataBytes
(int value) Set the number of data bytesvoid
setNumECBytes
(int value) Set the number of error correction blocksvoid
setNumRSBlocks
(int value) Set the number of Reed-Solomon blocksvoid
setNumTotalBytes
(int value) Set the number of total bytesvoid
setVersion
(int value) Set the version of the QR code.toString()
Prints all parameters
-
Field Details
-
NUM_MASK_PATTERNS
public static final int NUM_MASK_PATTERNS- See Also:
-
mode
-
ecLevel
-
version
private int version -
matrixWidth
private int matrixWidth -
maskPattern
private int maskPattern -
numTotalBytes
private int numTotalBytes -
numDataBytes
private int numDataBytes -
numECBytes
private int numECBytes -
numRSBlocks
private int numRSBlocks -
matrix
-
-
Constructor Details
-
QRCode
public QRCode()Create a QR-code object with unitialized parameters
-
-
Method Details
-
getMode
Mode used by the QR code to encode data into bits. Possible values: TERMINATOR, NUMERIC, ALPHANUMERIC, STRUCTURED_APPEND, BYTE, ECI, KANJI, FNC1_FIRST_POSITION, FNC2_SECOND_POSITION- Returns:
- Mode of the QR Code.
-
getECLevel
Possible error correction level values ranked from lowest error correction capability to highest: L, M, Q, H- Returns:
- Error correction level of the QR Code.
-
getVersion
public int getVersion()Together with error correction level, the version determines the information capacity of the QR code. Higher version numbers correspond with higher capacity. Ranges from 1 to 40.- Returns:
- Version of the QR Code.
-
getMatrixWidth
public int getMatrixWidth()- Returns:
- ByteMatrix width of the QR Code.
-
getMaskPattern
public int getMaskPattern()- Returns:
- Mask pattern of the QR Code.
-
getNumTotalBytes
public int getNumTotalBytes()- Returns:
- Number of total bytes in the QR Code.
-
getNumDataBytes
public int getNumDataBytes()- Returns:
- Number of data bytes in the QR Code.
-
getNumECBytes
public int getNumECBytes()- Returns:
- Number of error correction bytes in the QR Code.
-
getNumRSBlocks
public int getNumRSBlocks()- Returns:
- Number of Reedsolomon blocks in the QR Code.
-
getMatrix
- Returns:
- ByteMatrix data of the QR Code.
-
at
public int at(int x, int y) Retrieve the value of the module (cell) pointed by "x" and "y" in the matrix of the QR Code. 1 represents a black cell, and 0 represents a white cell.- Parameters:
x
- width coordinatey
- height coordinate- Returns:
- 1 for a black cell, 0 for a white cell
-
isValid
public boolean isValid()Check the validity of all member variables- Returns:
- true if all variables are valid, false otherwise
-
toString
Prints all parameters -
setMode
Set the data encoding mode of the QR code Possible modes: TERMINATOR, NUMERIC, ALPHANUMERIC, STRUCTURED_APPEND, BYTE, ECI, KANJI, FNC1_FIRST_POSITION, FNC2_SECOND_POSITION- Parameters:
value
- new data encoding mode
-
setECLevel
Set the error correction level of th QR code. Possible error correction level values ranked from lowest error correction capability to highest: L, M, Q, H- Parameters:
value
- new error correction level
-
setVersion
public void setVersion(int value) Set the version of the QR code. Together with error correction level, the version determines the information capacity of the QR code. Higher version numbers correspond with higher capacity. Range: 1 to 40.- Parameters:
value
- the new version of the QR code
-
setMatrixWidth
public void setMatrixWidth(int value) Sets the width of the byte matrix- Parameters:
value
- the new width of the matrix
-
setMaskPattern
public void setMaskPattern(int value) Set the masking pattern- Parameters:
value
- new masking pattern of the QR code
-
setNumTotalBytes
public void setNumTotalBytes(int value) Set the number of total bytes- Parameters:
value
- new number of total bytes
-
setNumDataBytes
public void setNumDataBytes(int value) Set the number of data bytes- Parameters:
value
- new number of data bytes
-
setNumECBytes
public void setNumECBytes(int value) Set the number of error correction blocks- Parameters:
value
- new number of error correction blocks
-
setNumRSBlocks
public void setNumRSBlocks(int value) Set the number of Reed-Solomon blocks- Parameters:
value
- new number of Reed-Solomon blocks
-
setMatrix
Set the byte-matrix- Parameters:
value
- the new byte-matrix
-
isValidMaskPattern
public static boolean isValidMaskPattern(int maskPattern) Check if "mask_pattern" is valid.- Parameters:
maskPattern
- masking pattern to check- Returns:
- true if the pattern is valid, false otherwise
-