Creating barcodes on a Django site

I want to add barcode generation to the Django website and wonder what the best library or api will be. My first advantage is that it can be called from Python - either written in Python or C / C ++ lib, which I can wrap with ctypes / SWIG. Otherwise, I can invoke the command line if it should be.

I need at least EAN and UPC characters.

I tried using pybarcode, but the image quality is too poor. And Elaphe looks promising, but from the Python interpreter, all I could do was QR code - an error of EAN and UPC (perhaps because the syntax / usage is not clear from the documentation).

+5
source share
3 answers

Use pybarcode and generate the barcode as SVG: http://packages.python.org/pyBarcode/barcode.html#creating-barcodes-as-svg

There are no problems with image quality in this case.

+6
source

reportlab can be a good alternative to pybarcode, especially when using some other functions.

There is a way for barcodes in Django with reportlab, works well for me. https://code.djangoproject.com/wiki/Barcodes

0
source

This thread is pretty old, but in case someone else is looking for an answer to this question ... code39 is a font, like most types of barcode. You can simply use Google fonts: https://fonts.google.com/specimen/Libre+Barcode+39+Extended+Text?selection.family=Libre+Barcode+39+Extended+Text

In addition to this option, you can host static files, one of the solutions could be this project on github:

https://github.com/Holger-Will/code-39-font

In this project, you only need the files associated with the size you need, and the code39_all.css file. You can delete the rest if you want.

For reference, I use both here:

{% load staticfiles %} {% load static %} <html> <head> <link href="https://fonts.googleapis.com/css?family=Libre+Barcode+39+Extended+Text" rel="stylesheet"> <link rel="stylesheet" href="{% static 'code-39-font-master/code39_all.css' %}"/> </head> <body> <style> body { font-family: 'Libre Barcode 39 Extended Text', cursive; font-size: 48px; } </style> <div>I'm just a code39 google font</div> <div><class="code_39_S">I'm generated with static files!</div> </body> </html> 
0
source

All Articles