Coder Social home page Coder Social logo

paperless-asn-qr-codes's Introduction

paperless-asn-qr-codes

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 machine consumption. The labels are Avery 4731 labels.

Installation

pip install paperless-asn-qr-codes

Usage

usage: paperless-asn-qr-codes [-h] [--format {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}] [--digits DIGITS] [--border] [--row-wise] [--num-labels NUM_LABELS] [--pages PAGES]
                              [--start-position START_POSITION]
                              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}
  --digits DIGITS, -d DIGITS
                        Number of digits in the ASN (default: 7, produces 'ASN0000001')
  --border, -b          Display borders around labels, useful for debugging the printer alignment
  --row-wise, -r        Increment the ASNs row-wise, go from left to right
  --num-labels NUM_LABELS, -n NUM_LABELS
                        Number of labels to be printed on the sheet
  --pages PAGES, -p PAGES
                        Number of pages to be printed, ignored if NUM_LABELS is set (default: 1)
  --start-position START_POSITION, -s START_POSITION
                        Define the starting position on the sheet, eighter as ROW:COLUMN or COUNT, both starting from 1 (default: 1:1 or 1)

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)
  • -d, --digits: Specifies the number of digits in the ASN (e.g. for the default number 7, the ASN will look like 'ASN0000001')
  • -b, --border: Generates the borders around the labels to help debug alignment issues (see Tips & Tricks)
  • -r, --row-wise: Increments the labels from left to right instead of top to bottom
  • -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.

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:

  • Avery L4731 (DIN A4 Labels)

Tips & Tricks

In case your printer has alignment issues, you can generate a PDF with borders around the labels by using the -b/--border option.

License

paperless-asn-qr-codes is distributed under the terms of the GPL-3.0 license.

paperless-asn-qr-codes's People

Contributors

fmeinicke avatar gparent avatar jcgruenhage avatar margau avatar xanderio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paperless-asn-qr-codes's Issues

Using error correction "H" where possible

I did some bigger changes to use segno instead of qrcode to generate the QR codes, with the main goal to use micro QR codes. I expected that they will result in better recognition rate at small dimensions.
But after some, indeed not strictly methodical, testing it seems that the best in case of recognition is the use of normal QR codes with error correction "H".
Therefore I suggest to set also with qrcode the error correction level to "H", since in my understanding qrcode in contrast to segno is not using the maximal possible error correction level.
I didn't filed an other pull request, as the changes are quite big and i don't want to hijack your great project. But maybe my observations are of interest for you, or some one else.

If some one is interested here are my test results. The labels where printed at 1200x600dpi with no toner saving on an OKI MC332dn, which was also used for scanning.

scan Setting scan lib orientation qrcode segno QR segno microQR EC „M“ segno microQR EC „Q“
100dpi grayscale zbar ~30° fail fail fail* -
150dpi grayscale zbar ~30° fail fail fail* -
300dpi grayscale zbar ~30° success success fail* -
150dpi grayscale zxing ~30° fail fail success -
100dpi grayscale zxing ~30° fail fail fail -
100dpi grayscale zxing ~0° fail fail fail -
150dpi grayscale zxing ~0° fail success fail -
100dpi grayscale zxing ~0° - 0 / 2 - 1 / 2
150dpi grayscale zxing ~0° - 1 / 2 - 0 / 2
150dpi color zxing ~0° - 2 / 2 - 0 / 2
200dpi grayscale zxing ~0° - 2 / 2 - 1 / 2
300dpi grayscale zxing ~0° - 2 / 2 - 2 / 2

*Most probably micro QR codes are not supported by zbar

Render issue with horizontal gutters

All of the sample labels are Avery brand, where there are no horizontal gutters (each label touches the one above/below it). So it was not obvious that there is a rendering bug.

What happens is if you set a horizontal gutter, it will allocate space above the first label. Thus, it artificially inflates the top margin.

For example, this was the settings I used for these labels (https://www.amazon.com/dp/B014IPO0US):

    "royalgreen1660": LabelInfo(
        labels_horizontal=7,
        labels_vertical=22,
        label_size=(25.4 * mm, 9.52 * mm),
        gutter_size=(2.5 * mm, 2.5 * mm),
        margin=(11.55 * mm, (8.73 - 2.5) * mm),
        pagesize=LETTER,
    ),

Note that I had to do 8.73 - 2.5 (subtract out the horizontal gutter height) to get it right.

Dockerfile to use

Hey,

i added a Dockerfile for myself, so i can run your tool without compromising my setup. Feel free to include / modify / ignore. :)

FROM python:alpine

VOLUME [ "/app" ]
WORKDIR /app

RUN pip install paperless-asn-qr-codes

ENTRYPOINT [ "paperless-asn-qr-codes" ]
CMD [ "1", "/app/labels.pdf" ]

Usage

If build with docker build -t paperless-asn-qr-code ., it can be used as follows:

docker run -it -v ./output:/app paperless-asn-qr-codes
# on windows: docker run -v .\ouput:/app paperless-asn-qr-codes

This creates a folder output in your current folder and place a labels.pdf in this directory. If you want to specify another starting label number, use the following command:

docker run -it -v ./output:/app paperless-asn-qr-codes <YOUR-NUMBER> labels.pdf
# on windows: docker run -it -v .\output:/app paperless-asn-qr-codes<YOUR-NUMBER> labels.pdf

So, if you need other options from paperless-asn-qr-codes, add it to the last command shown above.

If you want to get inside of the container, use the following:

docker run -it -v ./output:/app --entrypoint sh paperless-asn-qr-codes
# on windows: docker run -it -v .\output:/app --entrypoint sh paperless-asn-qr-codes 

Then you can use it like it is locally installed.

Bye.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.