Print text as a raster bit image from a Phomemo printer.
Project description
Phomemo printer - python utilities to allow printing text from the phomemo printer
I have not been able to print text to the Phomemo printer using standard ESC/POS print commands (if your printer does work with these commands, you should use the library here); to work around this, this library allows printing of text as a raster bit image.
Various methods to connect to the Phomemo printer and print images are excellently described here.
Tools were tested on a Phomemo M02 Pro printer.
Requirements
- python3
- bluetooth connection tools (if connecting to the printer over bluetooth)
Installation
sudo python3 setup.py install
This will create and install a CLI called phomemo_printer
on your PATH.
Usage
Connecting to the printer (bluetooth)
For non-bluetooth connection methods, see https://github.com/vivier/phomemo-tools.
The Debian package bluez
provides the utilities needed to scan for and connect to the printer via bluetooth.
- Find the bluetooth printer's MAC address
$ hcitool scan
Scanning ...
00:AA:13:41:11:A5 M02 Pro
- Determine which channel to connect to the device on
Format: sdptool browse {MAC_address}
$ sdptool browse 00:AA:13:41:11:A5
Browsing 00:AA:13:41:11:A5 ...
Service Name: SerialPort
Service RecHandle: 0x1000f
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 6
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0102
- Connect to the printer
Format: sudo rfcomm connect {device} {MAC_address} {channel}
. The device can be any /dev/rfcomm
device that is not in use.
$ sudo rfcomm connect /dev/rfcomm0 00:AA:13:41:11:A5 6
Connected /dev/rfcomm0 to on channel 6
Press CTRL-C for hangup
Sending text to the printer
CLI
Format: sudo phomemo_printer -d {device} -t "text to print"
sudo phomemo_printer -d /dev/rfcomm0 -t "Hello world"
Module import
Note that scripts that print to devices in /dev
will require superuser permissions to run.
from phomemo_printer.ESCPOS_printer import Printer
printer = Printer("/dev/rfcomm0")
printer.print_text("Hello world")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file phomemo_printer-1.0.0.tar.gz
.
File metadata
- Download URL: phomemo_printer-1.0.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4253d26f0f05a0b61f3aa15f6fc7fc42643ec1ee258d9753bd56540a074d571e |
|
MD5 | c80ee37812a0db4df59d40c55f9ec0cd |
|
BLAKE2b-256 | 95eabeb8881e5c184b5e82e296893b8465705353d9b3a24986f49b2545b911c0 |
File details
Details for the file phomemo_printer-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: phomemo_printer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4242d3471cc19a8b0dac5a5a24f167fc2768e2157bf0d4b0602099a2a9ffcfaf |
|
MD5 | 30bf5834d5539d88eb531f7a2d143b53 |
|
BLAKE2b-256 | d47a0ca0667fc6499ad075cadaa375cdad48871a1886d3f2430adb633df009aa |