This example shows how to create the payment part, which contains the Swiss QR Code as well as the same information as text output.
The payment part is created as a DIN A6 document, which can be placed on a A5 or A4 Document positioned in the bottom right corner.
import ch.codeblock.qrinvoice.OutputFormat;
import ch.codeblock.qrinvoice.PageSize;
import ch.codeblock.qrinvoice.QrInvoicePaymentPartCreator;
import ch.codeblock.qrinvoice.model.QrInvoice;
import ch.codeblock.qrinvoice.model.builder.QrInvoiceBuilder;
import java.time.LocalDate;
import java.time.Month;
import java.util.Locale;
// ..
final QrInvoice qrInvoice = // create using QrInvoiceBuilder;
// the resulting byte array contains the Swiss QR Code as PDF
final byte[] paymentPart = QrInvoicePaymentPartCreator
.create()
.qrInvoice(qrInvoice)
.outputFormat(OutputFormat.PDF)
.pageSize(PageSize.A4)
.locale(Locale.GERMAN)
.createPaymentPart();
Will generate a PDF that contains this paymentpart in the bottom right corner.
Here you can see the generated PDF