Barcode Label Printer
A Python package for generating barcode labels from JSON configuration and printing to various printers including Niimbot thermal printers.
Features
- Label Rendering: Generate SVG labels from JSON configuration
- Barcode Generation: Support for EAN13, Code128 barcode formats
- Multiple Element Types: Text, barcode, box, and picture elements
- Printer Support:
- Windows native printing
- PDF printing via SumatraPDF
- Niimbot thermal printers (USB/Bluetooth)
- Flexible Configuration: JSON-based label configuration
Installation
pip install barcode-label-printer
Optional Dependencies
For Windows native printing:
pip install barcode-label-printer[windows]
For Bluetooth support (Niimbot):
pip install barcode-label-printer[bluetooth]
Quick Start
Generate a Label
from barcode_label_printer import LabelRenderer
import json
# Load configuration
with open("label_config.json", "r") as f:
config = json.load(f)
# Render label to SVG
renderer = LabelRenderer()
renderer.render(config, "output_label.svg")
Print a Label
from barcode_label_printer import SvgPrinter
# Print to default printer
printer = SvgPrinter()
printer.print_svg_to_default("output_label.svg")
# Print to specific printer
printer.set_printer("HP LaserJet")
printer.print_svg("output_label.svg")
Print with Niimbot Printer
from barcode_label_printer import NiimbotPrinter
# Connect and print
printer = NiimbotPrinter(model="b21", connection_type="usb")
if printer.connect():
printer.print_image_file("label.png", density=3)
printer.disconnect()
Label Configuration Format
{
"canvas": {
"width_mm": 100,
"height_mm": 50
},
"elements": [
{
"type": "text",
"value": "Product Name",
"x_mm": 5,
"y_mm": 5,
"font_size_pt": 12,
"bold": true
},
{
"type": "barcode",
"barcode_type": "code128",
"value": "123456789012",
"x_mm": 5,
"y_mm": 15,
"width_mm": 80,
"height_mm": 20,
"write_text": false
}
]
}
Supported Element Types
Text Element
type: "text"value: Text contentx_mm,y_mm: Positionfont_size_pt: Font size in pointsbold: Booleantext_color: Color (default: "black")bg_color: Background color (optional)
Barcode Element
type: "barcode"barcode_type: "ean13" or "code128"value: Barcode valuex_mm,y_mm: Positionwidth_mm,height_mm: Sizewrite_text: Show text below barcode
Box Element
type: "box"x_mm,y_mm: Positionwidth_mm,height_mm: Sizefill_color: Fill color
Picture Element
type: "picture"svg_file: Path to SVG file (relative to config)x_mm,y_mm: Positionwidth_mm,height_mm: Size (optional, maintains aspect ratio)
Supported Niimbot Models
- B1, B18, B21, B31 (384px width)
- D11, D110 (96px width)
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Metadata
Release files for barcode-label-printer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| barcode_label_printer-0.1.0.tar.gz | 4.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| barcode_label_printer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / barcode_label_printer-0.1.0.tar.gz
| Download URL | barcode_label_printer-0.1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc03a760c6b6967b186ccc85e9df65d57f87a5243fefb1621bde28488e6110a6
|
|
BLAKE2b-256 checksum How to use checksums |
537d930ab87cd403f866423a6fee110cf02a8a699df3f715e17ed8d27bb3e747
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / barcode_label_printer-0.1.0-py3-none-any.whl
| Download URL | barcode_label_printer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f682c0e2727a2b820a4a6904c877db1f06f5514b7e0d4d85fc36c1b9e48f3ebe
|
|
BLAKE2b-256 checksum How to use checksums |
a3a165968751f3a08a1cee2ce8d2c10df67817572bd4da63e44baf7a8ab58b70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for barcode-label-printer 0.1.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.