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 in the bottom right corner.

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

// the resulting byte array contains the Swiss QR Code 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.

Payment Part & Receipt


The Swiss Implementation Guidelines QR-bill version 2.0 states in chapter 3.1 - The basics

If the payment part with receipt is integrated in a QR-bill in paper form, there must be a perforation between the bill details and the payment part and receipt.

There should be a perforation between the payment part and the receipt, if the QRbill is generated on paper.

and in chapter 3.7 - Notes about the QR-bill in PDF format:

If the QR-bill with payment part and receipt or the separate payment part with receipt are generated as a PDF document and sent electronically, the A6 format of the payment part and the receipt on the left must be indicated by lines. Each of these lines must bear the scissors symbol "" or alternatively the instruction "Separate before paying in" above the line (outside the payment part). This indicates to the debtor that he or she must neatly separate the payment part and receipt if they want to forward the QR-bill to their financial institution by post for payment, or settle it at the post office counter (branches or branches of partner organisations).

Summarized this means there are the following options:

  1. When printed (paper form), paper has to be perforated, no boundary lines necessary

  2. When produced as PDF, boundary lines are necessary

    1. with scissors as indicators

    2. with textual instruction above the payment part

. // as in the example at the beginning of the page
. // as in the example at the beginning of the page
. // as in the example at the beginning of the page