This is a fork of https://github.com/vowstar/ptouch-rs
I modified this to support network printing to the PT-P750W. We have a couple of these at PDX Hackerspace and want to use them with our link/asset-management tool and given that they have built-in Wifi we didn't want to have to hang them off other computers.
The path to CUPS support was fraught and ptouch already had good support for them but both the original and the new Rust version were built only to output over USB - they didn't even have options to write the raw results to a file. I'm not proficient in Rust - can barely read it at this point - so (yes...) I had a helpful AI make some changes to ptouch-rs:
- -o filename - output to a file changed to also output the raw print-job bytes when extension .bin used
- --transport [usb|raw|lpd] - if not writing to a file, what to do with the output - send over USB as traditional, raw TCP connection (default to port 9100), use lpd protocol (default to port 515)
- --host
- --port
- --media-width-mm MM - tape width for network use (ptouch can't query the printer)
- --lpd-queue NAME - queue to target on lpd transport
These forms have worked for us to print to a PT-P750W over the network:
ptouch print "Hello macOS" --model PT-P750W --media-width-mm 24 --transport=raw --host 10.0.12.71 ptouch print "Hello macOS" --model PT-P750W --media-width-mm 24 --transport=raw --host 10.0.12.71
Although we took a shot at implementing lpd support it's not working, but raw is.
Note that the printer must not be in PLite mode (controlled by the left-most button).
Rust tool for Brother P-Touch USB label printers. CLI and GUI.
- Print text labels with custom font, size, alignment and rotation
- Print images (PNG, JPEG, GIF, BMP, TIFF, WebP, SVG, and more)
- Compose multi-element labels (text + image + cut mark + padding)
- Save and reload designs as self-contained
.ptllayout files (images embedded), then print them from the GUI or CLI - Template layouts with
{{name}}placeholders and batch-print from a CSV - Chain print and multi-copy support
- GUI with live preview, zoom, and drag-and-drop element reordering
- Export to image (PNG, JPEG, BMP, GIF, TIFF, WebP) without a printer connected
- Feed and cut tape without printing
PT-9200DX, PT-2300, PT-2420PC, PT-9500PC, PT-2450PC, PT-18R, PT-1950, PT-2700, PT-1230PC, PT-2430PC, PT-2730, PT-H500, PT-E500, PT-E550W, PT-P700, PT-P750W, PT-D410, PT-D450, PT-D460BT, PT-D600, PT-D610BT, PT-P710BT, PT-E310BT, PT-E560BT and more.
Tape widths: 3.5mm, 6mm, 9mm, 12mm, 18mm, 24mm, 36mm.
Requires Rust stable toolchain.
Linux (libusb + udev):
sudo apt install libusb-1.0-0-dev libudev-dev # Debian/Ubuntu
sudo pacman -S libusb # Arch
sudo emerge dev-libs/libusb # Gentoo
cargo build --release --workspacemacOS / Windows: no extra dependencies.
cargo build --release --workspaceBinaries: target/release/ptouch (CLI), target/release/ptouch-gui (GUI).
ptouch-gui- Live label preview with zoom
- Add/edit/reorder text, images, cut marks, padding
- Free-angle text rotation with auto font sizing
- Tape width selection
- Save/Open layout (
.ptl) with images embedded for portability - Print to connected printer or export to image file
- Feed and cut tape without printing
# Print text
ptouch print "Hello World"
# Multi-line text
ptouch print "Line 1" "Line 2"
# Print with options
ptouch print "Label" -f "DejaVu Sans" -s 32 -a center
# Print image (PNG, JPEG, BMP, SVG, etc.)
ptouch print -i logo.png
# Text + image + cut mark
ptouch print "Name" -i photo.png -c
# Export to image file (no printer needed, format from extension)
ptouch print "Preview" -o label.png -w 76
ptouch print "Preview" -o label.bmp -w 76
# Print a layout designed in the GUI (images are embedded in the file)
ptouch print --layout label.ptl
# Render a layout to an image without a printer (uses the saved tape width)
ptouch print --layout label.ptl -o label.png
# Show printer info
ptouch info
# List supported models
ptouch listText in a layout may contain {{name}} placeholders. Fill them per print, or
drive a batch from a CSV file.
# See which placeholders a layout declares
ptouch print --layout badge.ptl --list-vars
# Fill placeholders for a single label
ptouch print --layout badge.ptl --set name=Alice --set id=A001
# One label per CSV row; the header row names the placeholders
ptouch print --layout badge.ptl --csv people.csv
# Batch to image files instead of a printer ({n} is the row number)
ptouch print --layout badge.ptl --csv people.csv -o 'badge-{n}.png'
# CSV from stdin, with a constant value applied to every row
cat people.csv | ptouch print --layout badge.ptl --csv - --set dept=Eng| Flag | Long | Description |
|---|---|---|
TEXT... |
Text lines (max 4) | |
-l |
--layout |
Print a saved layout file (.ptl); overrides content flags |
--set |
Set a layout placeholder, KEY=VALUE (repeatable) |
|
--csv |
Batch-print one label per CSV row (- for stdin) |
|
--list-vars |
List the placeholders a layout declares, then exit | |
--allow-missing |
Render placeholders with no value as blank | |
-i |
--image |
Image file path |
-o |
--output |
Export to image file instead of printing |
-f |
--font |
Font name (default: DejaVuSans) |
-s |
--size |
Font size in points (auto if omitted) |
-m |
--margin |
Top/bottom margin in pixels |
-a |
--align |
Text alignment: left, center, right |
-w |
--tape-width |
Force tape width in pixels (with -o) |
-c |
--cut |
Add cut mark |
-p |
--pad |
Add padding in pixels |
--chain |
Skip final feed/cut (chained labels) | |
--precut |
Cut before the label | |
--binarize |
Binarization: auto, threshold, dither | |
--copies |
Number of copies | |
--timeout |
Printer timeout in seconds | |
--debug |
Enable debug output |
Copy the udev rules file:
sudo cp udev/20-usb-ptouch-permissions.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm triggerCommunication goes through libusb, which on Windows can only reach a device
that uses the WinUSB driver. Out of the box Windows binds the printer to its
own driver (and the official Brother driver does the same), so ptouch info
reports Device not found until you switch it. See issue
#4.
- Download Zadig.
- Plug in the printer, then choose
Options > List All Devices. - Select your printer in the list (Brother VID
04F9). - Pick
WinUSBas the target driver and clickReplace Driver. - Run
ptouch infoagain.
After this the normal Brother software no longer sees the printer. Undo it any time by uninstalling or rolling back the driver in Device Manager.
No driver replacement is needed. Install libusb and it works directly:
brew install libusbIf claiming the device fails with a busy or access error, make sure the printer is not added as a print queue in System Settings.
crates/
ptouch-core/ -- USB transport, protocol, device/tape tables
ptouch-render/ -- Bitmap, text rendering, image loading, raster
ptouch-cli/ -- CLI binary
ptouch-gui/ -- GUI binary (egui)
This project's printer protocol and device layer is derived from ptouch-print by Dominic Radermacher and the ptouch-print contributors, which is licensed under the GPLv3. Thanks to them for the reverse engineering that made this possible.
Because of that, the project as a whole and the distributed ptouch and
ptouch-gui binaries are licensed GPL-3.0-or-later (see LICENSE).
Per-directory licensing (each source file carries an SPDX header):
| Path | License | Notes |
|---|---|---|
crates/ptouch-core/ |
GPL-3.0-or-later | Device table, flags, status protocol, command construction. Derived from ptouch-print. |
crates/ptouch-render/src/raster.rs |
GPL-3.0-or-later | Raster bit-packing. Derived from ptouch-print. |
crates/ptouch-render/ (other files) |
MIT | Bitmap, text, image loading, composition. Original work. |
crates/ptouch-cli/ |
MIT | Original work. |
crates/ptouch-gui/ |
MIT | Original work. |
The MIT-licensed files are reusable on their own under the MIT license (see
LICENSE-MIT). Any program that links ptouch-core, including the
binaries in this repository, is covered by the GPLv3. See NOTICE for
attribution details.