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 ErrorCorrectionLevelprivate intprivate ByteMatrixprivate intprivate Modestatic final intprivate intprivate intprivate intprivate intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintat(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, HintintgetMode()Mode used by the QR code to encode data into bits.intintintintintTogether with error correction level, the version determines the information capacity of the QR code.booleanisValid()Check the validity of all member variablesstatic booleanisValidMaskPattern(int maskPattern) Check if "mask_pattern" is valid.voidsetECLevel(ErrorCorrectionLevel value) Set the error correction level of th QR code.voidsetMaskPattern(int value) Set the masking patternvoidsetMatrix(ByteMatrix value) Set the byte-matrixvoidsetMatrixWidth(int value) Sets the width of the byte matrixvoidSet the data encoding mode of the QR code Possible modes: TERMINATOR, NUMERIC, ALPHANUMERIC, STRUCTURED_APPEND, BYTE, ECI, KANJI, FNC1_FIRST_POSITION, FNC2_SECOND_POSITIONvoidsetNumDataBytes(int value) Set the number of data bytesvoidsetNumECBytes(int value) Set the number of error correction blocksvoidsetNumRSBlocks(int value) Set the number of Reed-Solomon blocksvoidsetNumTotalBytes(int value) Set the number of total bytesvoidsetVersion(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
-
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
-
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
-