This example shows how to create the payment part & receipt (the "payment slip"), which contains the Swiss QR Code as well as the same information as text output.
The payment part & receipt is created as a DIN Lang (width: 210mm / height: 105mm) document, which can be placed on a A5 or A4 document positioned at the bottom.
import ch.codeblock.qrinvoice.FontFamily;
import ch.codeblock.qrinvoice.OutputFormat;
import ch.codeblock.qrinvoice.PageSize;
import ch.codeblock.qrinvoice.QrInvoicePaymentPartReceiptCreator;
import ch.codeblock.qrinvoice.model.QrInvoice;
import ch.codeblock.qrinvoice.model.builder.QrInvoiceBuilder;
import ch.codeblock.qrinvoice.output.PaymentPartReceipt;
import java.util.Locale;
// ...
final QrInvoice qrInvoice = // create using QrInvoiceBuilder;
final PaymentPartReceipt paymentPartReceipt = QrInvoicePaymentPartReceiptCreator
.create()
.qrInvoice(qrInvoice)
.outputFormat(OutputFormat.PDF)
.pageSize(PageSize.DIN_LANG)
.fontFamily(FontFamily.LIBERATION_SANS) // or HELVETICA, ARIAL
.locale(Locale.GERMAN)
.createPaymentPartReceipt();
// the resulting byte array contains the payment part & receipt as PDF
final byte[] paymentPartReceiptPdf = paymentPartReceipt.getData();
// meta data for the chosen OutputFormat for convenience
final String mimeType = paymentPartReceipt.getOutputFormat().getMimeType();
final String fileExtension = paymentPartReceipt.getOutputFormat().getFileExtension();
This will generate a PDF containing a payment part & receipt.
If you wish to generate a full A4 page with a blank header, set the pageSize
to PageSize.A4
.