mirror of
https://github.com/python-escpos/python-escpos
synced 2025-08-24 09:03:34 +00:00
Merge branch 'capabilities' into text-encoding
This commit is contained in:
@@ -18,6 +18,7 @@ Content
|
||||
user/raspi
|
||||
user/todo
|
||||
user/usage
|
||||
user/barcode
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
34
doc/user/barcode.rst
Normal file
34
doc/user/barcode.rst
Normal file
@@ -0,0 +1,34 @@
|
||||
Printing Barcodes
|
||||
-----------------
|
||||
:Last Reviewed: 2016-07-31
|
||||
|
||||
Most ESC/POS-printers implement barcode-printing.
|
||||
The barcode-commandset is implemented in the barcode-method.
|
||||
For a list of compatible barcodes you should check the manual of your printer.
|
||||
As a rule of thumb: even older Epson-models support most 1D-barcodes.
|
||||
To be sure just try some implementations and have a look at the notices below.
|
||||
|
||||
barcode-method
|
||||
~~~~~~~~~~~~~~
|
||||
The barcode-method is rather low-level and orients itself on the implementation of ESC/POS.
|
||||
In the future this class could be supplemented by a high-level class that helps the user generating the payload.
|
||||
|
||||
.. py:currentmodule:: escpos.escpos
|
||||
|
||||
.. automethod:: Escpos.barcode
|
||||
:noindex:
|
||||
|
||||
CODE128
|
||||
~~~~~~~
|
||||
Code128 barcodes need a certain format.
|
||||
For now the user has to make sure that the payload is correct.
|
||||
For alphanumeric CODE128 you have to preface your payload with `{B`.
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
from escpos.printer import Dummy, Serial
|
||||
p = Serial()
|
||||
# print CODE128 012ABCDabcd
|
||||
p.barcode("{B012ABCDabcd", "CODE128", function_type="B")
|
||||
|
||||
A very good description on CODE128 is also on `Wikipedia <https://en.wikipedia.org/wiki/Code_128>`_.
|
@@ -218,3 +218,34 @@ Here you can download an example, that will print a set of common barcodes:
|
||||
|
||||
* :download:`barcode.bin </download/barcode.bin>` by `@mike42 <https://github.com/mike42>`_
|
||||
|
||||
Hint: preprocess printing
|
||||
-------------------------
|
||||
|
||||
Printing images directly to the printer is rather slow.
|
||||
One factor that slows down the process is the transmission over e.g. serial port.
|
||||
|
||||
Apart from configuring your printer to use the maximum baudrate (in the case of serial-printers), there is not much
|
||||
that you can do.
|
||||
However you could use the :py:class:`escpos.printer.Dummy`-printer to preprocess your image.
|
||||
This is probably best explained by an example:
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
from escpos.printer import Serial, Dummy
|
||||
|
||||
p = Serial()
|
||||
d = Dummy()
|
||||
|
||||
# create ESC/POS for the print job, this should go really fast
|
||||
d.text("This is my image:\n")
|
||||
d.image("funny_cat.png")
|
||||
d.cut()
|
||||
|
||||
# send code to printer
|
||||
p._raw(d.output)
|
||||
|
||||
This way you could also store the code in a file and print later.
|
||||
You could then for example print the code from another process than your main-program and thus reduce the waiting time.
|
||||
(Of course this will not make the printer print faster.)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user