Class QRBill
Can also validate the bill data and encode and decode the text embedded in the QR code.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The height of an A4 sheet in portrait orientation, in mmstatic final double
The width of an A4 sheet in portrait orientation, in mmstatic final double
The height of the payment part, in mmstatic final double
The width of the payment part, in mmstatic final double
The height of a QR bill (payment part and receipt), in mmstatic final double
The width of a QR bill (payment part and receipt), in mmstatic final double
The height of the output format with extra space for horizontal separator line (payment part and receipt plus space for line and scissors), in mmstatic final double
The width of the output format with extra space for horizontal separator line (payment part and receipt plus space for line and scissors), in mmstatic final double
The height of the QR code, in mmstatic final double
The width of the QR code, in mmstatic final double
The height of the QR code with quiet zone, in mmstatic final double
The width of the QR code with quiet zone, in mm -
Method Summary
Modifier and TypeMethodDescriptionstatic Bill
decodeQrCodeText
(String text) Decodes the text embedded in the QR code and fills it into aBill
data structure.static void
Draws the QR bill (payment part and receipt) or QR code for the specified bill data onto the specified canvas.static void
drawSeparators
(SeparatorType separatorType, boolean withHorizontalLine, Canvas canvas) Draws the separator line(s) to the specified canvas.static String
encodeQrCodeText
(Bill bill) Encodes the text embedded in the QR code from the specified bill data.static byte[]
Generates a QR bill (payment part and receipt) or QR code as an SVG image or PDF document.static ValidationResult
Validates and cleans the bill data.
-
Field Details
-
A4_PORTRAIT_WIDTH
public static final double A4_PORTRAIT_WIDTHThe width of an A4 sheet in portrait orientation, in mm- See Also:
-
A4_PORTRAIT_HEIGHT
public static final double A4_PORTRAIT_HEIGHTThe height of an A4 sheet in portrait orientation, in mm- See Also:
-
QR_BILL_WIDTH
public static final double QR_BILL_WIDTHThe width of a QR bill (payment part and receipt), in mm- See Also:
-
QR_BILL_HEIGHT
public static final double QR_BILL_HEIGHTThe height of a QR bill (payment part and receipt), in mm- See Also:
-
QR_BILL_WITH_HORI_LINE_WIDTH
public static final double QR_BILL_WITH_HORI_LINE_WIDTHThe width of the output format with extra space for horizontal separator line (payment part and receipt plus space for line and scissors), in mm- See Also:
-
QR_BILL_WITH_HORI_LINE_HEIGHT
public static final double QR_BILL_WITH_HORI_LINE_HEIGHTThe height of the output format with extra space for horizontal separator line (payment part and receipt plus space for line and scissors), in mm- See Also:
-
QR_CODE_WIDTH
public static final double QR_CODE_WIDTHThe width of the QR code, in mm- See Also:
-
QR_CODE_HEIGHT
public static final double QR_CODE_HEIGHTThe height of the QR code, in mm- See Also:
-
QR_CODE_WITH_QUIET_ZONE_WIDTH
public static final double QR_CODE_WITH_QUIET_ZONE_WIDTHThe width of the QR code with quiet zone, in mm- See Also:
-
QR_CODE_WITH_QUIET_ZONE_HEIGHT
public static final double QR_CODE_WITH_QUIET_ZONE_HEIGHTThe height of the QR code with quiet zone, in mm- See Also:
-
PAYMENT_PART_WDITH
public static final double PAYMENT_PART_WDITHThe width of the payment part, in mm- See Also:
-
PAYMENT_PART_HEIGHT
public static final double PAYMENT_PART_HEIGHTThe height of the payment part, in mm- See Also:
-
-
Method Details
-
validate
Validates and cleans the bill data.The validation result contains the error and warning messages (if any) and the cleaned bill data.
For details about the validation result, see Bill data validation
- Parameters:
bill
- bill data- Returns:
- validation result
-
generate
Generates a QR bill (payment part and receipt) or QR code as an SVG image or PDF document.If the bill data is not valid, a
QRBillValidationError
is thrown, which contains the validation result. For details about the validation result, see Bill data validationThe graphics format is specified with
bill.getFormat().setGraphicsFormat(...)
. This method only supports the generation of SVG images and PDF files. For other graphics formats (in particular PNG), usedraw(net.codecrete.qrbill.generator.Bill, net.codecrete.qrbill.canvas.Canvas)
- Parameters:
bill
- the bill data- Returns:
- the generated QR bill (as a byte array encoded in the specified graphics format)
- Throws:
QRBillValidationError
- thrown if the bill data does not validate- See Also:
-
draw
Draws the QR bill (payment part and receipt) or QR code for the specified bill data onto the specified canvas.The QR bill or code are drawn at position (0, 0) extending to the top and to the right. Typically, the position (0, 0) is the bottom left corner of the canvas.
This methods ignores the formatting properties
bill.getFormat().getFontFamily()
andbill.getFormat().getGraphicsFormat()
. They can be set when the canvas instance passed to this method is created.If the bill data does not validate, a
QRBillValidationError
is thrown, which contains the validation result. For details about the validation result, see Bill data validationThe canvas will be initialized with
Canvas#setupPage
and it will be closed before returning the generated QR bill- Parameters:
bill
- the bill datacanvas
- the canvas to draw to- Throws:
QRBillValidationError
- thrown if the bill data does not validate
-
drawSeparators
public static void drawSeparators(SeparatorType separatorType, boolean withHorizontalLine, Canvas canvas) Draws the separator line(s) to the specified canvas.The separator lines are drawn assuming that the QR bill starts at position (0, 0) and extends the top and right. So position (0, 0) should be in the bottom left corner.
This method allows to add separator lines to an existing QR bill, e.g. on to an archived QR bill document.
- Parameters:
separatorType
- type of separator lineswithHorizontalLine
-true
if both the horizontal or vertical separator should be drawn,false
for the vertical separator onlycanvas
- the canvas to draw to
-
encodeQrCodeText
Encodes the text embedded in the QR code from the specified bill data.The specified bill data is first validated and cleaned.
If the bill data does not validate, a
QRBillValidationError
is thrown, which contains the validation result. For details about the validation result, see Bill data validation- Parameters:
bill
- the bill data to encode- Returns:
- the QR code text
- Throws:
QRBillValidationError
- thrown if the bill data does not validate
-
decodeQrCodeText
Decodes the text embedded in the QR code and fills it into aBill
data structure.A subset of the validations related to embedded QR code text is run. If the validation fails, a
QRBillValidationError
is thrown, which contains the validation result. See the error messages marked with a dagger in Bill data validation.- Parameters:
text
- the text to decode- Returns:
- the decoded bill data
- Throws:
QRBillValidationError
- thrown if the bill data does not validate
-