mirror of
https://github.com/inventree/inventree-docs.git
synced 2025-06-18 05:05:26 +00:00
_includes
docs
admin
app
assets
build
companies
extend
javascripts
part
releases
report
barcodes.md
build.md
labels.md
order.md
pack.md
report.md
test.md
start
stock
stylesheets
webfonts
contribute.md
credits.md
faq.md
features.md
index.md
.gitignore
LICENSE
README.md
mkdocs.yml
readthedocs.yml
requirements.txt
65 lines
1.6 KiB
Markdown
65 lines
1.6 KiB
Markdown
---
|
|
title: Barcode Generation
|
|
---
|
|
|
|
## Barcode Generation
|
|
|
|
Both [report](../report) and [label](../labels) 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:
|
|
|
|
```html
|
|
{% 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](https://pypi.org/project/python-barcode/) library.
|
|
|
|
To render a 1D barcode, use the `barcode` template tag, as shown in the example below:
|
|
|
|
```html
|
|
{% 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](https://en.wikipedia.org/wiki/Code_128) rendering. However [other barcode formats](https://python-barcode.readthedocs.io/en/stable/codes.html) are also supported:
|
|
|
|
```html
|
|
{% 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](https://pypi.org/project/qrcode/) library.
|
|
|
|
To render a QR code, use the `qrcode` template tag:
|
|
|
|
```html
|
|
{% raw %}
|
|
|
|
{% load barcode %}
|
|
|
|
<img class='custom_qr_class' src='{% qrcode "Hello world!" %}'>
|
|
{% endraw %}
|
|
```
|