Skip to main content

QR platba SVG/PNG QR code and SPAYD string generator.

Project description

python-qrplatba

Stable Version

Python library for generating QR codes for QR platba.

Example QR platba image

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 QRPlatbaGenerator is deprecated and will be removed in a future version. Use from qrplatba import QRPlatbaGenerator instead. The SPAYD string generator class is available as from qrplatba import SpaydGenerator.
  • Updated default settings: Default box_size changed from 12 to 10, producing smaller SVG output with clean integer mm dimensions (e.g. 50mm x 51mm instead of 59.4mm x 60.36mm). Pass box_size=12 to make_image() to restore the previous overall dimensions. Note: SVG visual changes (border thickness, text height) apply at all sizes; box_size=12 only restores the overall dimensions, not the exact visual appearance.
  • SVG visual output changed: border thickness doubled (LINE_SIZE 0.25 to 0.5), text area below the QR code is taller (FONT_HEIGHT 8 to 10), and text positioning adjusted. These changes affect all SVGs regardless of box_size.
  • Dropped support for Python 3.8
  • Added Python 3.12, 3.13 and 3.14
  • Added SpaydGenerator class for standalone SPAYD string generation
  • Refactored QRPlatbaGenerator to inherit from SpaydGenerator
  • 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 black with ruff format for code formatting
  • Fixed _format_item_string silently dropping zero values (e.g. x_vs=0)
  • Added comprehensive test suite including backward compatibility and PNG rendering tests
  • Release tags now use v prefix (e.g. v1.2.0 instead of 1.2.0)

1.1.1 (24 April 2023)

  • Added compatibility with lxml library. Fixes TypeError when using this library while lxml is 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.

  • Updated requirements to support the latest qrcode version
  • Added support for custom output sizes using box_size and border parameters
  • Changed legacy setuptools to poetry, later migrated to uv
  • Dropped support for Python 2.x and <3.7
  • Changed license to MIT
  • Added unit tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qrplatba-1.2.0.tar.gz (218.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qrplatba-1.2.0-py3-none-any.whl (219.4 kB view details)

Uploaded Python 3

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

Hashes for qrplatba-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f3a3a7be6c10ed8616711aa930500bee79957dc88529becad8c417a759434245
MD5 d58d4a938250d7fcdff50c2b61e87418
BLAKE2b-256 015b9e3d8aaec2040baf7714a858cc7a3b3df482daeba1c929705bb88f529580

See more details on using hashes here.

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

Hashes for qrplatba-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fcc82051cdeb68780ec9496cb9cc3329fb59dc6c8e8668a4b2d7560f64a3e9f
MD5 eb4a68e0fe2a9ca9d69742b54b5a106c
BLAKE2b-256 7ba4c4bb2198a838db4bbfdec686db6d298db4f9e286b50dfd902c0c3dd55292

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page