Swiss QR-bill generation library per SIX IG QR-bill v2.3.
Generates the complete payment part (Zahlteil) with receipt in three output formats: PDF, SVG (text as paths), and PNG (rasterized at configurable DPI).
Output formats
to_pdf/2— native PDF (no system dependencies)to_svg/2— SVG with text converted to paths (requirespdftocairo)to_png/2— rasterized PNG at configurable DPI (requirespdftocairo)
Output sizes
:payment_slip— 210 x 105 mm (default):a4— 210 x 297 mm (payment slip at bottom):qr_code— 56 x 56 mm (QR code only)
Languages
:de, :fr, :it, :en, :rm (Romansh)
Usage
creditor = SwissQrBill.Address.new("Muster AG", "Bahnhofstrasse", "1", "8001", "Zürich", "CH")
debtor = SwissQrBill.Address.new("Max Muster", "Hauptstrasse", "42", "3000", "Bern", "CH")
{:ok, ref} = SwissQrBill.Reference.QrReferenceGenerator.generate("210000", "313947143000901")
bill =
SwissQrBill.new()
|> SwissQrBill.set_creditor(creditor)
|> SwissQrBill.set_creditor_information("CH44 3199 9123 0008 8901 2")
|> SwissQrBill.set_payment_amount("CHF", 2500.25)
|> SwissQrBill.set_debtor(debtor)
|> SwissQrBill.set_payment_reference(:qrr, ref)
|> SwissQrBill.set_additional_information("Invoice 2024-001")
{:ok, pdf} = SwissQrBill.to_pdf(bill, language: :de)
{:ok, svg} = SwissQrBill.to_svg(bill, language: :de)
{:ok, png} = SwissQrBill.to_png(bill, language: :de, dpi: 300)
Summary
Functions
Adds an alternative scheme. Maximum 2 allowed.
Creates a new empty QR bill.
Sets additional information (unstructured message and/or bill information).
Sets the creditor address.
Sets the creditor IBAN. Accepts an IBAN string or a CreditorInformation struct.
Sets the debtor address. Optional.
Sets the payment amount. Amount can be nil for bills without a fixed amount.
Sets the payment reference.
Generates the complete payment part as PDF binary. Validates the bill first.
Generates the complete payment part as PNG.
Rasterized from the PDF at the specified DPI for print-quality output.
Requires pdftocairo (poppler-utils) to be installed.
Generates the complete payment part as SVG.
Text is converted to glyph outlines (paths) for guaranteed rendering on all devices.
Requires pdftocairo (poppler-utils) to be installed.
Validates the QR bill data.
Returns {:ok, bill} or {:error, errors}.
Types
@type t() :: %SwissQrBill{ additional_information: SwissQrBill.AdditionalInformation.t() | nil, alternative_schemes: [SwissQrBill.AlternativeScheme.t()], creditor: SwissQrBill.Address.t() | nil, creditor_information: SwissQrBill.CreditorInformation.t() | nil, debtor: SwissQrBill.Address.t() | nil, payment_amount: SwissQrBill.PaymentAmount.t() | nil, payment_reference: SwissQrBill.PaymentReference.t() | nil }
Functions
Adds an alternative scheme. Maximum 2 allowed.
@spec new() :: t()
Creates a new empty QR bill.
Sets additional information (unstructured message and/or bill information).
@spec set_creditor(t(), SwissQrBill.Address.t()) :: t()
Sets the creditor address.
@spec set_creditor_information(t(), String.t() | SwissQrBill.CreditorInformation.t()) :: t()
Sets the creditor IBAN. Accepts an IBAN string or a CreditorInformation struct.
@spec set_debtor(t(), SwissQrBill.Address.t()) :: t()
Sets the debtor address. Optional.
Sets the payment amount. Amount can be nil for bills without a fixed amount.
@spec set_payment_reference( t(), SwissQrBill.PaymentReference.reference_type(), String.t() | nil ) :: t()
Sets the payment reference.
Generates the complete payment part as PDF binary. Validates the bill first.
Options
:language—:de,:fr,:it,:en, or:rm(default::de):output_size—:payment_slip(210x105mm),:a4(210x297mm), or:qr_code(56x56mm). Default::payment_slip:branding— whentrue, adds a small localized "Created by qrbill.dev" line (default:false). With:qr_codethe canvas grows by 4mm to fit the line below the code.
Generates the complete payment part as PNG.
Rasterized from the PDF at the specified DPI for print-quality output.
Requires pdftocairo (poppler-utils) to be installed.
Options
:language—:de,:fr,:it,:en, or:rm(default::de):output_size—:payment_slip(210x105mm),:a4(210x297mm), or:qr_code(56x56mm). Default::payment_slip:dpi— resolution (default: 300):branding— whentrue, adds a small localized "Created by qrbill.dev" line (default:false)
Generates the complete payment part as SVG.
Text is converted to glyph outlines (paths) for guaranteed rendering on all devices.
Requires pdftocairo (poppler-utils) to be installed.
Options
:language—:de,:fr,:it,:en, or:rm(default::de):output_size—:payment_slip(210x105mm),:a4(210x297mm), or:qr_code(56x56mm). Default::payment_slip:branding— whentrue, adds a small localized "Created by qrbill.dev" line (default:false)
Validates the QR bill data.
Returns {:ok, bill} or {:error, errors}.