2
0
mirror of https://github.com/inventree/inventree-website.git synced 2025-04-28 05:26:44 +00:00

Added multi printer docu für Zebra label printer plugin

This commit is contained in:
Michael 2024-04-13 13:51:55 +02:00
parent bf24b84a4b
commit 3fcdca481c

View File

@ -17,12 +17,14 @@ tags: Label Printer Zebra ZPL
---
Zebra Label Printer Plugin for Inventree
This is a label printing plugin for [InvenTree](https://inventree.org), which provides support for Zebra Label printers .
It was only tested with GK420T but should work for other ZPL printers too. It uses the ZPL library to
convert the png data provided by InvenTree to Zebra's bitmap format.
This is a label printing plugin for [InvenTree](https://inventree.org), which provides
support for Zebra Label printers. It was only tested with GK420T but should work for
other ZPL printers too. It uses the ZPL library to convert the png data provided by
InvenTree to Zebra's bitmap format.
It can output the print data either to a local printer connected to the computer via USB or to a network printer
with an IP address. The output can be configured in the InvenTree plugin user interface.
It can output the print data either to a local printer connected to the computer via
USB or to a network printer with an IP address. The output can be configured in the
InvenTree plugin user interface.
Error handling is very basic.
@ -74,8 +76,8 @@ is passed directly to the printer without any checks. So be careful when editing
here.
## Label Template
The label needs a template described in html and css. The template should start with a page definition
that defines the label size as shown below:
The label needs a template described in html and css. The template should
start with a page definition that defines the label size as shown below:
```
@page {
@ -89,8 +91,27 @@ that defines the label size as shown below:
}
```
The height and width parameters are defined in the InvenTree admin panel in the label section. These values
have to fit the label size that is in the printer. See the example templates for details on template definition.
The height and width parameters are defined in the InvenTree admin panel
in the label section. These values have to fit the label size that is in
the printer. See the example templates for details on template definition.
## Multi printer hack
We have the requirement to print labels in different sizes. As we do not
want to change the reel for each print we set up a second printer loaded
with a different label size. InvenTree is not yet able to handle different
printers. So I added a multi printer hack. You can define a key with an IP
address in the label meta data:
```
{"ip_address":"xxx.yyy.zzz.eee"}
{"darkness":xx}
```
If the printer driver finds that key, the IP address from the printer settings
is overwritten with the address from the meta data. So the print will end up
in another printer.
Only the IP address and darkness can be overwritten so far. All other settings remain.
## How it works
First import all the stuff you need. Here we use the translation mechanism from Django for multi language support.
@ -172,7 +193,7 @@ We can put the result of this directly into the ZPL library.
```python
l = zpl.Label(Height, Width, dpmm)
l.origin(0, 0)
li.set_darkness(darkness)
...
l.write_graphic(label_image, Width)
l.endorigin()