-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""This module provides classes for building a single paperless ASN label with a given layout.""" | ||
from dataclasses import dataclass, KW_ONLY | ||
from reportlab.lib.units import mm | ||
from reportlab_qrcode import QRCodeImage | ||
|
||
@dataclass | ||
class LabelInfo: | ||
"""Class for modeling label sheet info""" | ||
|
||
_: KW_ONLY | ||
digits: int | ||
|
||
class Label: | ||
"""Class for building the label""" | ||
|
||
def __init__(self, start_asn): | ||
self.current = start_asn | ||
|
||
def render(self, canvas, x_size, y_size): | ||
barcode_value = f"ASN{self.current:0{7}d}" | ||
|
||
qr = QRCodeImage(barcode_value, size=y_size * 0.9) | ||
qr.drawOn(canvas, 1 * mm, y_size* 0.05) | ||
canvas.setFont("Helvetica", 2 * mm) | ||
canvas.drawString(y_size, (y_size - 2 * mm) / 2, barcode_value) | ||
self.current += 1 |
1 change: 0 additions & 1 deletion
1
paperless_asn_qr_codes/LabelSheet.py → paperless_asn_qr_codes/label_sheet.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters