Any good pdf417 Barcode libraries for Python?
Asked Answered
T

3

5

I'm looking for a good python module to generate pdf417 barcodes. Has anyone used one they liked?

Ideally I would like one with as few dependencies as possible, and one that runs on both linux and MacOSX.

Tunnage answered 16/8, 2011 at 14:46 Comment(3)
Which ones have you tried? The guys over at reportlab.com have an open source version of their library that's performed well for me.Perception
I'm using reportlab for a code128 barcode, but I don't think they support pdf417. Do you know if it is supported, I could find any documentation on what types they support anymore.Tunnage
Are you looking for a library to generate the barcodes? decode the barcodes? both?Cystic
S
7

We recently had to approach this problem as well, and being a Python shop we wanted a Python solution. It become clear the elaphe is the project that had the potential to actually accomplish pdf 417 barcode.

However what we found was it errors by todays standards, and so we entered the hunt to fix the library. Turns out elaphe must generate an outdated form of *.eps post script that can't be interpreted by ghost script and this is where the bar code generation fails.

Well fortunately elphae uses a common library behind the scenes called Barcode Writer in Pure PostScript @ http://bwipp.terryburton.co.uk

This common backend library which has many projects in multi-languages using it to generate projects. The fix specifically for us was to fork elaphe, and correct it's *.eps file generation.

To determine what is broken in the *.eps, look at this other site that is made using postscriptbarcode, and it let's you generate the pdf417 barcode online (as well as other formats): http://www.terryburton.co.uk/barcodewriter/generator/

Once you generate a pdf417 barcode it gives you the option to download the .png, .jpg, and YES the .eps file!

Using this .eps file you can pipe it to ghost script and tweak the parameterization to get the exact pdf417 barcode you are looking for. Then take this result and integrate it into the elaphe library and actually get a pull request on that thing ....

Seems to be a bit of work, but nothing that can't be knocked out in an afternoon. It is ideal to get the elaphe library back in shape to generate these without making this enhancement.

Please note that the performance of this approach for us is a few seconds to generate this barcode due to the fact it creates the 2000 line eps file and pipes it to ghost script which generates another image file that we send back as the final barcode result. This is not as performance as code128 with reportlab.

Perhaps room for optimizations: Is pillow faster than PIL in anyway? Do we need all the parts of the eps file to generate the barcode of type pdf417? Other ways to optimize?

Anyway, great question Ken and I hope you find this to be a great answer.

Salomie answered 28/6, 2013 at 14:54 Comment(0)
C
2

I guess the issue in elaphe reported by Matteius in 2013 has been fixed, since the issues and commit logs show updates on the pdf417 topic since then.

Anyway, there are now a few other options (got the list with either pip search elaphe or pip search pdf417) :

  • elaphe ;
  • elaphe3 (fork of elaphe tested against python3) ;
  • candybar (no documentation ? also a webservice) ;
  • pdf417gen ;
  • treepoem (about the name : barcode -> bark ode -> tree poem =D ) — edit : didn't dig the issue, but as of today generation of PDF417 seems broken.

All but pdf417gen support several types of barcodes.

Note that the documentation of bwipp (on which are based elaphe and treepoem) only mentions 5 levels of error correction (1 to 5), while pdf417gen claims to support 9 security levels (0 to 8).

Cloyd answered 20/1, 2017 at 10:42 Comment(1)
Interesting, I just saw your comment about this and will make a note to try it out.Salomie
L
0

Reportlab does have an extension called rlbarcode, but this one does not include support for pdf417 codes. I do not know of any other extension for reportlab including support for pdf417 bar codes.

Anyway, if you are interested in generation of pdf417 codes from python, you may be interested in this project: elaphe.

I have still not tested it (in fact, I need to generate pdf417 from python, and I found this thread as well as the elaphe project page) I am going to download the elaphe tools in order to test it right now.

Lanyard answered 27/6, 2012 at 8:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.