This project lets you print text messages to an MXW01 Cat Printer using a Node.js CLI and a Go BLE print worker.
- Node.js (v16+ recommended)
- Go (v1.18+ recommended)
- canvas Node.js package
- github.com/go-ble/ble Go package
- DotMatrix and DotMatrixBold TTF fonts in
fonts/directory - MXW01 Cat Printer (or compatible)
- Linux or macOS (tested on Ubuntu)
git clone <this-repo-url>
cd <repo-directory>npm install canvas express body-parser- Install Go (or see below):
sudo apt install golang-go # or use the official Go tarball for latest version - Build the Go print worker:
go get github.com/go-ble/ble/linux/att@v0.0.0-20240122180141-8c5522f54333 go get github.com/go-ble/ble/linux/hci/socket@v0.0.0-20240122180141-8c5522f54333 go build -o catprinter catprinter.go chmod +x catprinter
- Place
dotmatrix.ttfanddotmatrixbold.ttfin thefonts/directory. - These are required for the Node.js script to render text in the correct style.
Print a message to your Cat Printer:
node print.js <printer-mac-address> "Your message here"- Example:
node print.js 48:0F:57:12:30:9D "Hello, Cat Printer!" - This will:
- Render the message as a PNG (rotated 180°, black text on white background)
- Call the Go print worker to send the image to your printer via BLE
Run the server
node server.jsOpen http://:3000 on your machine to print
- Make sure your printer is on and not connected to any other device.
- If you see BLE errors, try running as root or with BLE permissions:
sudo ./catprinter debug-receipt.png <printer-mac-address>
- If the printout is blank or garbled, check the generated
debug-receipt.pngfor correct orientation and contrast.
- You can adjust font size, line height, and intensity in the scripts.
- The Go print worker expects a 384px wide, 1-bit PNG image.
Enjoy your Cat Printer!