diff --git a/doc/index.rst b/doc/index.rst index 8e876a0..060fc7f 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -18,6 +18,7 @@ Content user/raspi user/todo user/usage + user/barcode .. toctree:: :maxdepth: 1 diff --git a/doc/user/barcode.rst b/doc/user/barcode.rst new file mode 100644 index 0000000..5d45419 --- /dev/null +++ b/doc/user/barcode.rst @@ -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 `_. diff --git a/src/escpos/constants.py b/src/escpos/constants.py index 74b26eb..93721cb 100644 --- a/src/escpos/constants.py +++ b/src/escpos/constants.py @@ -168,10 +168,7 @@ BARCODE_TYPE_B = { 'NW7': _SET_BARCODE_TYPE(71), 'CODABAR': _SET_BARCODE_TYPE(71), # Same as NW7 'CODE93': _SET_BARCODE_TYPE(72), - # These are all the same barcode, but using different charcter sets - 'CODE128A': _SET_BARCODE_TYPE(73) + b'{A', # CODE128 character set A - 'CODE128B': _SET_BARCODE_TYPE(73) + b'{B', # CODE128 character set B - 'CODE128C': _SET_BARCODE_TYPE(73) + b'{C', # CODE128 character set C + 'CODE128': _SET_BARCODE_TYPE(73), 'GS1-128': _SET_BARCODE_TYPE(74), 'GS1 DATABAR OMNIDIRECTIONAL': _SET_BARCODE_TYPE(75), 'GS1 DATABAR TRUNCATED': _SET_BARCODE_TYPE(76),