Skip to main content

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.

Alternatively, install via pip:

python3 -m pip install phomemo_printer

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.

  1. Find the bluetooth printer's MAC address
$ hcitool scan

Scanning ...
	00:AA:13:41:11:A5	M02 Pro
  1. 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
  1. 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

phomemo_printer-1.0.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

phomemo_printer-1.0.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file phomemo_printer-1.0.1.tar.gz.

File metadata

  • Download URL: phomemo_printer-1.0.1.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

Hashes for phomemo_printer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b8bac8ad5a01ed87ef2ae7f2fccd95bd96dc27d207c043a50d74b710dd59e494
MD5 8a86a4762c24b1abfd55cce01f04bb22
BLAKE2b-256 7bfd6645a712049514cf20e96da56d4e6ac33d457b215f52f91bbcdff2d0ca15

See more details on using hashes here.

File details

Details for the file phomemo_printer-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: phomemo_printer-1.0.1-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

Hashes for phomemo_printer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4333521865e7572795de1b1ba48428404c9cb8d27895eede0d2a94b26faf8ea0
MD5 1dabb6501326afb970b5a82be4799e9c
BLAKE2b-256 b06e46762fb88f81802afc4498a703187e9235db534fbf6d7fee9785e20551f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page