* Add builtin plugin for auto-issuing orders * Add plugin to auto-issue orders * Add placeholder documentation * Fix typo * Adds image macro - To replace img.html - includes checking if file exists * Fix tooltips * More docs * Adjust plugin settings filters * docs * More docs * More docs * Updates * Less restrictive URL checking * Refactor build order page * Fix typo * Allow 429 * Debug output * More debug * Construct assets dir * Cleanup * Update docs README * Refactoring more pages * Fix image link * Fix SSO settings * Add hook to check for missing settings - Ensure that all settings are documented! * Add missing user settings * Update docstring * Tweak SSO.md * Image updates * More updates * Tweaks * Exclude orders without a target_date * Fix for issuing build orders * Further refactoring * Fixes * Image refactoring * More refactoring * More refactoring * Refactor app images * Fix pathing issues * Suppress some openapidocs warnings in logs (much easier to debug docs build issues) * Fix image reference * Reduce error messages * Fix image links * Fix image links * Reduce docs log output * Ensure settings are loaded before displaying them * Fix for UI test * Fix unit test * Test tweaks
3.9 KiB
title
| title |
|---|
| Barcode Generation |
Barcode Generation
Both report and label templates can render custom barcode data to in-line images.
Barcode Template Tags
To use the barcode tags inside a label or report template, you must load the barcode template tags at the top of the template file:
{% raw %}
<!-- Load the barcode helper functions -->
{% load barcode %}
{% endraw %}
Barcode Image Data
The barcode template tags will generate an image tag with the barcode data encoded as a base64 image. The image data is intended to be rendered as an img tag:
{% raw %}
{% load barcode %}
<img class='custom_class' src='{% barcode "12345678" %}'>
{% 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:
::: report.templatetags.barcode.barcode options: show_docstring_description: False show_source: False
Example
{% raw %}
<!-- Don't forget to load the barcode helper! -->
{% load barcode %}
<img class='custom_class' src='{% barcode "12345678" %}'>
{% endraw %}
Additional Options
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:
::: report.templatetags.barcode.qrcode options: show_docstring_description: false show_source: False
Example
{% raw %}
{% extends "label/label_base.html" %}
{% load l10n i18n barcode %}
{% block style %}
.qr {
position: absolute;
left: 0mm;
top: 0mm;
{% localize off %}
height: {{ height }}mm;
width: {{ height }}mm;
{% endlocalize %}
}
{% endblock style %}
{% block content %}
<img class='qr' src='{% qrcode "Hello world!" fill_color="white" back_color="blue" %}'>
{% endblock content %}
{% endraw %}
which produces the following output:
{{ image("report/qrcode.png", "QR Code") }}
!!! tip "Documentation" Refer to the qrcode library documentation for more information
Data Matrix
!!! info "ppf.datamatrix" Data Matrix codes are generated using the ppf.datamatrix library.
Data Matrix Codes provide an alternative to QR codes for encoding data in a two-dimensional matrix. To render a Data Matrix code, use the datamatrix template tag:
::: report.templatetags.barcode.datamatrix options: show_docstring_description: false show_source: False
Example
{% raw %}
{% extends "label/label_base.html" %}
{% load l10n i18n barcode %}
{% block style %}
.qr {
position: absolute;
left: 0mm;
top: 0mm;
{% localize off %}
height: {{ height }}mm;
width: {{ height }}mm;
{% endlocalize %}
}
{% endblock style %}
{% block content %}
<img class='qr' src='{% datamatrix "Foo Bar" back_color="yellow" %}'>
{% endblock content %}
{% endraw %}
which produces the following output:
{{ image("report/datamatrix.png", "Data Matrix") }}