QR platba SVG/PNG QR code and SPAYD string generator.
Project description
python-qrplatba
Python library for generating QR codes for QR platba.
See http://qr-platba.cz/pro-vyvojare/ for more information about the specification (available only in czech).
from qrplatba import QRPlatbaGenerator
from datetime import datetime, timedelta
due = datetime.now() + timedelta(days=14)
generator = QRPlatbaGenerator('123456789/0123', 400.56, x_vs=2034456, message='text', due_date=due)
img = generator.make_image()
img.save('example.svg')
# PNG export (requires: pip install qrplatba[png])
img.save('example.png', output_format='png', zoom=2)
# optional: custom box size and border
img = generator.make_image(box_size=20, border=4)
# optional: get SVG as a string.
# Encoding has to be 'unicode', otherwise it will be encoded as bytes
svg_data = img.to_string(encoding='unicode')
Installation
To install qrplatba, simply:
$ pip install qrplatba
For PNG export support:
$ pip install qrplatba[png]
Note on image file formats
This module generates SVG files by default. PNG export is supported when installed with qrplatba[png] – see the example above.
For other formats (e.g. PDF), you can use external tools like libRSVG to convert SVG images.
libRSVG
libRSVG renders SVG files using cairo and supports many output image formats. It can also be used directly in console with rsvg-convert command.
$ rsvg-convert -f pdf example.svg -o example.pdf
SPAYD format
QR Platba uses SPAYD format (application/x-shortpaymentdescriptor) for encoding information related to bank transfer. You can generate the SPAYD string directly using SpaydGenerator:
from qrplatba import SpaydGenerator
generator = SpaydGenerator('123456789/0123', 400.56, x_vs=2034456, message='text', due_date=due)
spayd = generator.get_text()
License
This software is licensed under MIT license since version 1.0.0.
Changelog
1.2.0 (5 March 2026)
[!CAUTION] Breaking changes in
1.2.0:
- Changed package structure:
from qrplatba.spayd import QRPlatbaGeneratoris deprecated and will be removed in a future version. Usefrom qrplatba import QRPlatbaGeneratorinstead. The SPAYD string generator class is available asfrom qrplatba import SpaydGenerator.- Updated default settings: Default
box_sizechanged from 12 to 10, producing smaller SVG output with clean integer mm dimensions (e.g.50mm x 51mminstead of59.4mm x 60.36mm). Passbox_size=12tomake_image()to restore the previous overall dimensions. Note: SVG visual changes (border thickness, text height) apply at all sizes;box_size=12only restores the overall dimensions, not the exact visual appearance.- SVG visual output changed: border thickness doubled (
LINE_SIZE0.25 to 0.5), text area below the QR code is taller (FONT_HEIGHT8 to 10), and text positioning adjusted. These changes affect all SVGs regardless ofbox_size.- Dropped support for Python 3.8
- Added Python 3.12, 3.13 and 3.14
- Added
SpaydGeneratorclass for standalone SPAYD string generation - Refactored
QRPlatbaGeneratorto inherit fromSpaydGenerator - Added PNG export support via
save(output_format='png')with optional dependency (pip install qrplatba[png]) - Updated SVG font stack to
Inter, Arial, Helvetica, sans-serif - Migrated from Poetry to uv
- Replaced
blackwithruff formatfor code formatting - Fixed
_format_item_stringsilently dropping zero values (e.g.x_vs=0) - Added comprehensive test suite including backward compatibility and PNG rendering tests
- Release tags now use
vprefix (e.g.v1.2.0instead of1.2.0)
1.1.1 (24 April 2023)
- Added compatibility with
lxmllibrary. FixesTypeErrorwhen using this library whilelxmlis installed in the same virtualenv.
1.1.0 (5 April 2023)
- Dropped support for Python 3.7
- Added pre-commit, ruff for code linting and formatting
1.0.0 (4 April 2023)
Warning: While the API is mostly backwards compatible, the look and size of the generated QR codes has changed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qrplatba-1.2.0.tar.gz.
File metadata
- Download URL: qrplatba-1.2.0.tar.gz
- Upload date:
- Size: 218.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3a3a7be6c10ed8616711aa930500bee79957dc88529becad8c417a759434245
|
|
| MD5 |
d58d4a938250d7fcdff50c2b61e87418
|
|
| BLAKE2b-256 |
015b9e3d8aaec2040baf7714a858cc7a3b3df482daeba1c929705bb88f529580
|
File details
Details for the file qrplatba-1.2.0-py3-none-any.whl.
File metadata
- Download URL: qrplatba-1.2.0-py3-none-any.whl
- Upload date:
- Size: 219.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fcc82051cdeb68780ec9496cb9cc3329fb59dc6c8e8668a4b2d7560f64a3e9f
|
|
| MD5 |
eb4a68e0fe2a9ca9d69742b54b5a106c
|
|
| BLAKE2b-256 |
7ba4c4bb2198a838db4bbfdec686db6d298db4f9e286b50dfd902c0c3dd55292
|