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.

#include <qrinvoice/model/qr_invoice.hpp>
#include <qrinvoice/payment_part_receipt_creator.hpp>

// ...

const qrinvoice::model::qr_invoice qr_invoice = // create using qr_invoice::builder;

qrinvoice::payment_part_receipt_creator ppr_creator;
const qrinvoice::output::payment_part_receipt ppr = ppr_creator.qr_invoice(qr_invoice)
        .page_size(qrinvoice::page_size::din_lang)
        .in_german()
        .output_format(qrinvoice::output_format::pdf)
        .create_payment_part_receipt();

// the resulting byte vector contains the payment part & receipt as PDF
// "qrinvoice::output::output::byte" is "unsigned char"
const std::vector<qrinvoice::output::output::byte> &data = ppr.get_data();
const size_t i = ppr.get_size();

This will generate a PDF containing a payment part & receipt.

Payment Part & Receipt

Options

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

ppr_creator.qr_invoice(qr_invoice)
. // as in the example at the beginning of the page
.without_boundary_lines()
.create_payment_part_receipt();
ppr_creator.qr_invoice(qr_invoice)
. // as in the example at the beginning of the page
.with_boundary_lines()
.with_scissors()
.create_payment_part_receipt();
ppr_creator.qr_invoice(qr_invoice)
. // as in the example at the beginning of the page
.with_boundary_lines()
.without_scissors()
.with_separation_text()
.create_payment_part_receipt();

Boundary Lines and Margins

Please see Payment Part & Receipt Output Options for explanations.

Additional boundary line margins

ppr_creator.qr_invoice(qr_invoice)
. // as in the example at the beginning of the page
.with_boundary_lines_with_margins();
. // as in the example at the beginning of the page
.create_payment_part_receipt();

which is equivalent to

#include <qrinvoice/boundary_lines.hpp>

ppr_creator.qr_invoice(qr_invoice)
. // as in the example at the beginning of the page
// or qrinvoice::boundary_lines::enabled
// or qrinvoice::boundary_lines::none
.boundary_lines(qrinvoice::boundary_lines::enabled_with_margins);
. // as in the example at the beginning of the page
.create_payment_part_receipt();

Additional print margins

Additional (1mm) print margin can be requested as follows:

ppr_creator.qr_invoice(qr_invoice)
. // as in the example at the beginning of the page
.with_additional_print_margin();
. // as in the example at the beginning of the page
.create_payment_part_receipt();

which is equivalent to

ppr_creator.qr_invoice(qr_invoice)
. // as in the example at the beginning of the page
.additional_print_margin(true);
. // as in the example at the beginning of the page
.create_payment_part_receipt();