2
0
mirror of https://github.com/inventree/inventree-docs.git synced 2025-04-28 21:56:49 +00:00
inventree-docs/docs/report/barcodes.md
Oliver Walters b072165f75 Fixing pretty much every existing internal link.
Sometimes, it pays to RTFD
2021-06-10 15:27:55 +10:00

1.6 KiB

title
title
Barcode Generation

Barcode Generation

Both report and label templates can render custom barcode data to in-line images.

!!! info "img" Barcode data must be rendered inside an <img> tag.

Inside the template file (whether it be for printing a label or generating a custom report), the following code will need to be included at the top of the template file:

{% raw %}
<!-- Load the barcode helper functions -->
{% load barcode %}
{% endraw %}

1D Barcode

!!! info "python-barcode" One dimensional barcodes (e.g. Code128) are generated using the python-barcode library.

To render a 1D barcode, use the barcode template tag, as shown in the example below:

{% raw %}

<!-- Don't forget to load the barcode helper! -->
{% load barcode %}

<img class='custom_class' src='{% barcode "12345678" %}'>

{% endraw %}

The default barcode renderer will generate a barcode using Code128 rendering. However other barcode formats are also supported:

{% raw %}

{% load barcode %}

<img class='custom_class' src='{% barcode "12345678" barcode_class="Code39" %}>
{% endraw %}

QR-Code

!!! info "qrcode" Two dimensional QR codes are generated using the qrcode library.

To render a QR code, use the qrcode template tag:

{% raw %}

{% load barcode %}

<img class='custom_qr_class' src='{% qrcode "Hello world!" %}'>
{% endraw %}