feat: add support for choosing a label format

This commit is contained in:
Marvin Gaube 2023-11-25 15:12:31 +01:00 committed by Jan Christian Grünhage
parent e3da948064
commit a6b9eb5069
3 changed files with 19 additions and 8 deletions

View file

@ -10,6 +10,14 @@ for machine consumption. The labels are Avery 4731 labels.
pip install paperless-asn-qr-codes
```
## Supported Sheets
Some different sheet types are supported with the `--format` argument, however, not all are tested.
Default is Avery L4731.
Currently tested and known working are:
- Avery L4731 (DIN A4 Labels)
## License
`paperless-asn-qr-codes` is distributed under the terms of the

View file

@ -26,16 +26,16 @@ from reportlab.lib.units import mm
# page size
labelInfo = {
4731: ( 7, 27, (25.4*mm, 10*mm), (2.5*mm, 0), (9*mm, 13.5*mm), A4),
"averyL4731": ( 7, 27, (25.4*mm, 10*mm), (2.5*mm, 0), (9*mm, 13.5*mm), A4),
# 2.6 x 1 address labels
5160: ( 3, 10, (187, 72), (11, 0), (14, 36), LETTER),
5161: ( 2, 10, (288, 72), (0, 0), (18, 36), LETTER),
"avery5160": ( 3, 10, (187, 72), (11, 0), (14, 36), LETTER),
"avery5161": ( 2, 10, (288, 72), (0, 0), (18, 36), LETTER),
# 4 x 2 address labels
5163: ( 2, 5, (288, 144), (0, 0), (18, 36), LETTER),
"avery5163": ( 2, 5, (288, 144), (0, 0), (18, 36), LETTER),
# 1.75 x 0.5 return address labels
5167: ( 4, 20, (126, 36), (0, 0), (54, 36), LETTER),
"avery5167": ( 4, 20, (126, 36), (0, 0), (54, 36), LETTER),
# 3.5 x 2 business cards
5371: ( 2, 5, (252, 144), (0, 0), (54, 36), LETTER),
"avery5371": ( 2, 5, (252, 144), (0, 0), (54, 36), LETTER),
}
RETURN_ADDRESS = 5167

View file

@ -20,10 +20,13 @@ def main():
description='CLI Tool for generating paperless ASN labels with QR codes')
parser.add_argument('start_asn')
parser.add_argument('output_file')
parser.add_argument('--format', choices=avery_labels.labelInfo.keys(), default="averyL4731")
args = parser.parse_args()
global startASN
startASN = int(args.start_asn)
label = avery_labels.AveryLabel(4731)
label = avery_labels.AveryLabel(args.format)
label.open(args.output_file)
label.render(render, 189 )
# by default, we render all labels possible on a single sheet
count = avery_labels.labelInfo[args.format][0]*avery_labels.labelInfo[args.format][1]
label.render(render, count )
label.close()