From 991efddbd662ea6144b5ca3c50ce1286baba1bde Mon Sep 17 00:00:00 2001 From: belono Date: Tue, 16 May 2023 12:19:13 +0200 Subject: [PATCH] Update barcode examples and docs --- doc/user/barcode.rst | 17 +++++++++-------- examples/barcodes.py | 4 ++-- examples/software_barcode.py | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/doc/user/barcode.rst b/doc/user/barcode.rst index 5d45419..11b12a7 100644 --- a/doc/user/barcode.rst +++ b/doc/user/barcode.rst @@ -1,17 +1,18 @@ Printing Barcodes ----------------- -:Last Reviewed: 2016-07-31 +:Last Reviewed: 2023-05-16 -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. +Many printers implement barcode printing natively. +This hardware renderered barcodes are fast but the supported formats are limited by the printer itself and different between models. +However, almost all printers support printing images, so barcode renderization can be performed externally by software and then sent to the printer as an image. +As a drawback, this operation is much slower and the user needs to know and choose the image implementation method supported by the printer's commandset. 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. +Since version 3.0, the ``barcode`` method unifies the previous ``barcode`` (hardware) and ``soft_barcode`` (software) methods. +It is able to choose automatically the best printer implementation for barcode printing based on the capabilities of the printer and the type of barcode desired. +To achieve this, it relies on the information contained in the escpos-printer-db profiles. +The chosen profile needs to match the capabilities of the printer as closely as possible. .. py:currentmodule:: escpos.escpos diff --git a/examples/barcodes.py b/examples/barcodes.py index ef7944b..16c8083 100644 --- a/examples/barcodes.py +++ b/examples/barcodes.py @@ -2,10 +2,10 @@ from escpos.printer import Usb # Adapt to your needs -p = Usb(0x0416, 0x5011, profile="POS-5890") +p = Usb(0x0416, 0x5011, profile="TM-T88II") # Print software and then hardware barcode with the same content -p.soft_barcode("code39", "123456") +p.barcode("123456", "CODE39", width=2, force_software=True) p.text("\n") p.text("\n") p.barcode("123456", "CODE39") diff --git a/examples/software_barcode.py b/examples/software_barcode.py index 0fdaaee..7c949dd 100644 --- a/examples/software_barcode.py +++ b/examples/software_barcode.py @@ -5,5 +5,5 @@ from escpos.printer import Usb p = Usb(0x0416, 0x5011, profile="POS-5890") # Some software barcodes -p.soft_barcode("code128", "Hello") -p.soft_barcode("code39", "1234") +p.barcode("Hello", "code128", width=2, force_software="bitImageRaster") +p.barcode("1234", "code39", width=2, force_software=True)