Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ASN Tag configurable #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ options:
- `-n`, `--num-labels`: Number of lables to be printed on the sheet
- `-p`, `--pages`: Number of pages to be generated, ignored if -n is present.
- `-s`, `--start-position`: Positon of first label to be printed, eighter defined as ROW:COLUMN or NUMBER. Starting from 1 eg. to use the whole sheet it would be 1:1 or 1. Useful if you have a partly used sheet from using `-n`.
- `-t`, `--prefixasn`: Set prefix instead of original ASN. (Default is ASN) (see [Tips & Tricks](#tips--tricks))

## Supported Sheets
Some different sheet types are supported with the `-f`/`--format` argument, however, not all are tested.
Expand All @@ -70,6 +71,8 @@ Currently tested and known working are:
In case your printer has alignment issues, you can generate a PDF with borders around the labels by using the
`-b`/`--border` option.

If you set your own ASN-Prefix (see [paperless-ngx docu)(https://docs.paperless-ngx.com/configuration/#PAPERLESS_CONSUMER_ASN_BARCODE_PREFIX)

## License

`paperless-asn-qr-codes` is distributed under the terms of the
Expand Down
12 changes: 11 additions & 1 deletion paperless_asn_qr_codes/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
def render(c, x, y):
global startASN
global digits
barcode_value = f"ASN{startASN:0{digits}d}"
global tagASN
barcode_value = f"{prefixASN}{startASN:0{digits}d}"
startASN = startASN + 1

qr = QRCodeImage(barcode_value, size=y * 0.9)
Expand Down Expand Up @@ -81,10 +82,19 @@ def _start_position(arg):
type=_start_position,
help="Define the starting position on the sheet, eighter as ROW:COLUMN or COUNT, both starting from 1 (default: 1:1 or 1)",
)
parser.add_argument(
"--prefixasn",
"-t",
type=str,
default="ASN",
help="Set the prefix-tag intead of ASN Number (default: ASN)",
)

args = parser.parse_args()
global startASN
global digits
global prefixASN
prefixASN = str(args.prefixasn)
startASN = int(args.start_asn)
digits = int(args.digits)
label = avery_labels.AveryLabel(
Expand Down