Skip to main content
https://img.shields.io/pypi/v/qrbill.svg

Python library to generate Swiss QR-bills

From 2020, Swiss payment slips will progressively be converted to the QR-bill format. Specifications can be found on https://www.paymentstandards.ch/

This library is aimed to produce properly-formatted QR-bills as SVG files either from command line input or by using the QRBill class.

Installation

You can easily install this library with:

$ pip install qrbill

Command line usage example

Minimal:

$ qrbill --account "CH5800791123000889012" --creditor-name "John Doe"
  --creditor-postalcode 2501 --creditor-city "Biel"

More complete:

$ qrbill --account "CH44 3199 9123 0008 8901 2" --reference-number "210000000003139471430009017"
--creditor-name "Robert Schneider AG" --creditor-street "Rue du Lac 1268"
--creditor-postalcode "2501" --creditor-city "Biel"
--additional-information "Bill No. 3139 for garden work and disposal of cuttings."
--debtor-name "Pia Rutschmann" --debtor-street "Marktgasse 28" --debtor-postalcode "9400"
--debtor-city "Rorschach" --language "de"

For usage:

$ qrbill -h

If no –output SVG file path is specified, the SVG file will be named after the account and the current date/time and written in the current directory.

Note that if you don’t like the automatic line wrapping in the human-readable part of some address, you can replace a space by a newline sequence in the creditor or debtor name, line1, line2, or street to force a line break in the printed addresses. (e.g. –creditor-street “Rue des Quatorze Contours du Cheminndu Creux du Van”) The data encoded in the QR bill will not have the newline character. It will be replaced by a regular space.

Python usage example

>>> from qrbill import QRBill
>>> my_bill = QRBill(
        account='CH5800791123000889012',
        creditor={
            'name': 'Jane', 'pcode': '1000', 'city': 'Lausanne', 'country': 'CH',
        },
        amount='22.45',
    )
>>> my_bill.as_svg('/tmp/my_bill.svg')

Outputting as PDF or bitmap

If you want to produce a PDF version of the resulting bill, we suggest using the svglib <https://pypi.org/project/svglib/> library. It can be used on the command line with the svg2pdf script, or directly from Python:

>>> import tempfile
>>> from qrbill import QRBill
>>> from svglib.svglib import svg2rlg
>>> from reportlab.graphics import renderPDF

>>> my_bill = QRBill(
        account='CH5800791123000889012',
        creditor={
            'name': 'Jane', 'pcode': '1000', 'city': 'Lausanne', 'country': 'CH',
        },
        amount='22.45',
    )
>>> with tempfile.TemporaryFile(encoding='utf-8', mode='r+') as temp:
>>>     my_bill.as_svg(temp)
>>>     temp.seek(0)
>>>     drawing = svg2rlg(temp)
>>> renderPDF.drawToFile(drawing, "file.pdf")

or to produce a bitmap image output:

>>> from reportlab.graphics import renderPM
>>> dpi = 300
>>> drawing.scale(dpi/72, dpi/72)
>>> renderPM.drawToFile(drawing, "file.png", fmt='PNG', dpi=dpi)

Running tests

You can run tests by executing:

$ PYTHONPATH=. python tests/test_qrbill.py

Sponsors

https://seantis.ch/static/img/logo.svg

Metadata

Release files for qrbill 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qrbill 1.3.0
File Size Uploaded Provenance Actions
qrbill-1.3.0.tar.gz 22.6 kB Without provenance Details for qrbill-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qrbill 1.3.0
File Interpreter ABI Platform Actions
qrbill-1.3.0-py3-none-any.whl Python 3 none any Details for qrbill-1.3.0-py3-none-any.whl

Total release size: 37.6 kB

Release files / qrbill-1.3.0.tar.gz

Download URL qrbill-1.3.0.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e094be3a0cfc8360ee3f150a1c71b7aa4992f1e99d8526a9e9f678aa68dee5f4
BLAKE2b-256 checksum
How to use checksums
8846361da253154baae5708b3f5c6031ca60ea29a2bd25fce4923fcd3fad02e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / qrbill-1.3.0-py3-none-any.whl

Download URL qrbill-1.3.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
696b20a2628d30f954f62628b33d519dc8f772e845bba55b673ec31847375c8a
BLAKE2b-256 checksum
How to use checksums
190be9b237aadff7fa2d4b132b440f0d5c4a455b800480c965a61e4f07d6b837
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for qrbill 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page