2
0
mirror of https://github.com/inventree/inventree-docs.git synced 2025-04-27 21:26:43 +00:00
inventree-docs/docs/report/barcodes.md
2022-12-22 21:44:44 +11:00

2.2 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 %}

You can also pass further python-barcode supported parameters as well:

{% raw %}

{% load barcode %}

<img class='barcode' src='{% barcode part.IPN barcode_class="Code128" write_text=0 background="red" %}'>
{% 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 %}

Additional parameters can be passed to the qrcode function for rendering:

{% raw %}
<img class='custom_qr_class' src='{% qrcode "Hello world!" fill_color="green" back_color="blue" %}'>
{% endraw %}

!!! tip "Documentation" Refer to the qrcode library documentation for more information