Compare commits

...

6 commits

Author SHA1 Message Date
Markus Siebert ffadfcff77
Merge 55643c3051 into 278046ae90 2024-04-17 21:22:26 +02:00
Florian Meinicke 278046ae90 Update README.md
Add documentation for the command line arguments and options
2024-04-17 21:18:11 +02:00
Florian Meinicke 279a3ee0ea Add shorthand flags for --format and --border 2024-04-17 21:18:11 +02:00
Florian Meinicke 267c5c7011 Add default value for the output_file argument 2024-04-17 21:18:11 +02:00
Florian Meinicke 14cd97e1e2 Add types and help strings for the positional arguments 2024-04-17 21:18:11 +02:00
gparent d95dea4196 Correct gutter size and margin on avery5167 2024-04-17 21:17:07 +02:00
3 changed files with 46 additions and 12 deletions

View file

@ -1,7 +1,7 @@
# paperless-asn-qr-codes # paperless-asn-qr-codes
`paperless-asn-qr-codes` is a command line utility for generating ASN labels `paperless-asn-qr-codes` is a command line utility for generating ASN labels
for paperless with both a human readable representation, as well as a QR code for paperless with both a human-readable representation, as well as a QR code
for machine consumption. The labels are Avery 4731 labels. for machine consumption. The labels are Avery 4731 labels.
## Installation ## Installation
@ -10,10 +10,41 @@ for machine consumption. The labels are Avery 4731 labels.
pip install paperless-asn-qr-codes pip install paperless-asn-qr-codes
``` ```
## Supported Sheets ## Usage
Some different sheet types are supported with the `--format` argument, however, not all are tested.
Default is Avery L4731. ```
usage: paperless-asn-qr-codes [-h] [--format {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}] [--border] start_asn output_file
CLI Tool for generating paperless ASN labels with QR codes
positional arguments:
start_asn The value of the first ASN
output_file The output file to write to (default: labels.pdf)
options:
-h, --help show this help message and exit
--format {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}, -f {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}
--border, -b Display borders around labels, useful for debugging the printer alignment
```
### Mandatory arguments
- `<start_asn>`: The value of the first ASN to generate
### Optional arguments
- `<output_file>`: The name of the output file to write to (default: labels.pdf)
---
- `-h`, `--help`: Shows the help message
- `-f`, `--format`: Selects the format of the output sheet (see [Supported Sheets](#supported-sheets))
- `-b`, `--border`: Generates the borders around the labels to help debug alignment issues (see [Tips & Tricks](#tips--tricks))
## Supported Sheets
Some different sheet types are supported with the `-f`/`--format` argument, however, not all are tested.
The default is Avery L4731.
Currently tested and known working are: Currently tested and known working are:
- Avery L4731 (DIN A4 Labels) - Avery L4731 (DIN A4 Labels)
@ -21,7 +52,7 @@ Currently tested and known working are:
## Tips & Tricks ## Tips & Tricks
In case your printer has alignment issues, you can generate a PDF with borders around the labels by using the In case your printer has alignment issues, you can generate a PDF with borders around the labels by using the
`--border` option. `-b`/`--border` option.
## License ## License

View file

@ -2,7 +2,8 @@ from dataclasses import dataclass, KW_ONLY
from collections.abc import Iterator from collections.abc import Iterator
from reportlab.pdfgen import canvas from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import LETTER, A4 from reportlab.lib.pagesizes import LETTER, A4
from reportlab.lib.units import mm from reportlab.lib.units import mm, inch
# Usage: # Usage:
# label = AveryLabels.AveryLabel(5160) # label = AveryLabels.AveryLabel(5160)
@ -67,9 +68,9 @@ labelInfo: dict[str, LabelInfo] = {
"avery5167": LabelInfo( "avery5167": LabelInfo(
labels_horizontal=4, labels_horizontal=4,
labels_vertical=20, labels_vertical=20,
label_size=(126, 36), label_size=(1.75 * inch, 0.5 * inch),
gutter_size=(0, 0), gutter_size=(0.3 * inch, 0),
margin=(54, 36), margin=(0.3 * inch, 0.5 * inch),
pagesize=LETTER, pagesize=LETTER,
), ),
# 3.5 x 2 business cards # 3.5 x 2 business cards

View file

@ -2,6 +2,7 @@ import argparse
from reportlab.lib.units import mm from reportlab.lib.units import mm
from reportlab_qrcode import QRCodeImage from reportlab_qrcode import QRCodeImage
from paperless_asn_qr_codes import avery_labels from paperless_asn_qr_codes import avery_labels
@ -21,13 +22,14 @@ def main():
prog="paperless-asn-qr-codes", prog="paperless-asn-qr-codes",
description="CLI Tool for generating paperless ASN labels with QR codes", description="CLI Tool for generating paperless ASN labels with QR codes",
) )
parser.add_argument("start_asn") parser.add_argument("start_asn", type=int, help="The value of the first ASN")
parser.add_argument("output_file") parser.add_argument("output_file", type=str, default="labels.pdf", help="The output file to write to (default: labels.pdf)")
parser.add_argument( parser.add_argument(
"--format", choices=avery_labels.labelInfo.keys(), default="averyL4731" "--format", "-f", choices=avery_labels.labelInfo.keys(), default="averyL4731"
) )
parser.add_argument( parser.add_argument(
"--border", "--border",
"-b",
action="store_true", action="store_true",
help="Display borders around labels, useful for debugging the printer alignment", help="Display borders around labels, useful for debugging the printer alignment",
) )