DOC add example on printing commands from binary files

This commit is contained in:
Patrick Kanzler 2016-05-01 15:27:15 +02:00
parent 6a2673d01d
commit a0dc993f2f
No known key found for this signature in database
GPG Key ID: F07F07153306FCEF
2 changed files with 27 additions and 0 deletions

BIN
doc/download/barcode.bin Normal file

Binary file not shown.

View File

@ -177,6 +177,33 @@ And for a network printer::
host: 127.0.0.1
port: 9000
Advanced Usage: Print from binary blob
--------------------------------------
Imagine you have a file with ESC/POS-commands in binary form. This could be useful for testing capabilities of your
printer with a known working combination of commands.
You can print this data with the following code, using the standard methods of python-escpos. (This is an
advantage of the fact that `_raw()` accepts binary strings.)
::
from escpos import printer
p = printer.Serial() # adapt this to your printer model
file = open("binary-blob.bin", "rb") # read in the file containing your commands in binary-mode
data = file.read()
file.close()
p._raw(data)
That's all, the printer should then print your data. You can also use this technique to let others reproduce an issue
that you have found. (Just "print" your commands to a File-printer on your local filesystem.)
However, please keep in mind, that often it is easier and better to just supply the code that you are using.
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>`_
How to update your code for USB printers
----------------------------------------