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.FontFamily;
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;

final PaymentPart paymentPart = QrInvoicePaymentPartCreator
    .create()
    .qrInvoice(qrInvoice)
    .outputFormat(OutputFormat.PDF)
    .pageSize(PageSize.A4)
    .fontFamily(FontFamily.HELVETICA)
    .locale(Locale.GERMAN)
    .createPaymentPart();

// the resulting byte array contains the Swiss QR Code as PDF
final byte[] paymentPartPdf = paymentPart.getData();

// meta data for the chosen OutputFormat for convenience
final String mimeType = paymentPart.getOutputFormat().getMimeType();
final String fileExtension = paymentPart.getOutputFormat().getFileExtension();

This will generate a PDF containing a payment part in the bottom right corner.

Payment Part