From 93584538ff270cbdafc6fa885c3e9d45315f8e3c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 22 Feb 2021 17:28:35 +1100 Subject: [PATCH] Update label printing docs - Remove references to blabel --- docs/releases/0.1.7.md | 8 +++++ docs/report/barcodes.md | 64 ++++++++++++++++++++++++++++++++++ docs/report/labels.md | 76 ++++++++++++++++++++++++++++++++++------- mkdocs.yml | 3 +- 4 files changed, 138 insertions(+), 13 deletions(-) create mode 100644 docs/report/barcodes.md diff --git a/docs/releases/0.1.7.md b/docs/releases/0.1.7.md index 2955981..022b5f2 100644 --- a/docs/releases/0.1.7.md +++ b/docs/releases/0.1.7.md @@ -8,6 +8,14 @@ title: Release 0.1.7 ## New Features +### Label Printing + +Label printing functionality has been simplified and brought into line with the PDF reporting functionality. + +[#1342](https://github.com/inventree/InvenTree/pull/1342) represents a significant refactor of the label printing code. + +!!! info "More Information" + Refer to the [label printing documentation](../../report/labels) for further details. ## Major Bug Fixes | PR | Description | diff --git a/docs/report/barcodes.md b/docs/report/barcodes.md new file mode 100644 index 0000000..8726c71 --- /dev/null +++ b/docs/report/barcodes.md @@ -0,0 +1,64 @@ +--- +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 `` 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 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 %} + + +{% load barcode %} + + + +{% 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 %} + + +{% endraw %} +``` diff --git a/docs/report/labels.md b/docs/report/labels.md index a80f1cc..c9fd87e 100644 --- a/docs/report/labels.md +++ b/docs/report/labels.md @@ -4,18 +4,16 @@ title: Custom Labels ## Custom Labels -InvenTree supports printing of custom template-based labels, using the [blabel](https://github.com/Edinburgh-Genome-Foundry/blabel) Python library. +InvenTree supports printing of custom template-based labels, using the [WeasyPrint](https://weasyprint.org/) PDF generation engine. Custom labels can be generated using simple HTML templates, with support for QR-codes, and conditional formatting using the Jinja template engine. -!!! info "Documentation" - Refer to the [blabel documentation](https://edinburgh-genome-foundry.github.io/blabel/) for further information, and examples of the available features Simple (generic) label templates are supplied 'out of the box' with InvenTree - however support is provided for generation of extremely specific custom labels, to meet any particular requirement. ## Label Templates -Label templates are written using a mixture of [HTML](https://www.w3schools.com/html/) and [CSS](https://www.w3schools.com/css). The blabel library is based on [weasyprint](https://weasyprint.org/), which supports a *subset* of HTML and CSS features. In addition to supporting HTML and CSS formatting, the label templates support the Jinja templating engine, allowing conditional formatting of the label data. +Label templates are written using a mixture of [HTML](https://www.w3schools.com/html/) and [CSS](https://www.w3schools.com/css). [Weasyprint](https://weasyprint.org/) templates support a *subset* of HTML and CSS features. In addition to supporting HTML and CSS formatting, the label templates support the Jinja templating engine, allowing conditional formatting of the label data. A label template is a single `.html` file which is uploaded to the InvenTree server by the user. @@ -29,8 +27,7 @@ Below is a reasonably simple example of a label template which demostrates much {% raw %} - +
{{ location.name }} @@ -99,11 +96,9 @@ Location Name: {{ location.name }} {% endraw %} ``` -### QR Codes +### Barcodes -`blabel` supports barcodes and QR codes 'out of the box'. Passing data to render as a barcode or QR code is handled in the template file itself. - -Refer to the [blabel docs](https://edinburgh-genome-foundry.github.io/blabel/) for further information. +Refer to the [barcode documentation](../barcodes). ### Conditional Formatting @@ -127,10 +122,67 @@ As an example, consider a label template for a StockItem. A user may wish to def To restrict the label accordingly, we could set the *filters* value to `part__IPN=IPN123`. -### Built-In Templates +## Built-In Templates The InvenTree installation provides a number of simple *default* templates which can be used as a starting point for creating custom labels. These built-in templates can be disabled if they are not required. +Built-in templates can also be used to quickly scaffold custom labels, using template inheritance. + +### Base Template + +For example, InvenTree provides a *base* template from which all of the default label templates are derived. This *base* template provides the essentials for generating a label: + +```html +{% raw %} + + + + + + {% block content %} + + {% endblock %} + + +{% endraw %} +``` + +### Extend Base Template + +To extend this template in a custom uploaded label, simply extend as follows: + +```html +{% raw %} +{% extends "label/label_base.html" %} + +{% block style %} + +{% endblock %} + +{% block content %} + +{% endblock %} + +{% endraw %} +``` + + ## Stock Item Labels Stock Item label templates are used to generate labels for individual Stock Items. diff --git a/mkdocs.yml b/mkdocs.yml index b7677cb..619d88d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -71,12 +71,13 @@ nav: - Sales Orders: companies/so.md - Report: - Templates: report/report.md + - Labels: report/labels.md - Reports: - Test Reports: report/test.md - Packing List: report/pack.md - Build Order: report/build.md - Order: report/order.md - - Labels: report/labels.md + - Barcodes: report/barcodes.md - Admin: - Admin Interface: admin/admin.md - User Permissions: admin/permissions.md