escpresso
A virtual ESC/POS thermal receipt printer emulator with real-time GUI preview. Accepts ESC/POS commands over TCP and renders receipts visually, making it useful for POS development, testing, and debugging without a physical printer.
Features
- TCP server on port 9100 (standard POS printer port)
- Real-time GUI preview using egui — see receipts render as data arrives
- 58mm and 80mm paper sizes with switchable UI
- Text formatting — bold, underline, double width/height, inverted, alignment
- Raster graphics — ESC * bit images and GS v 0 raster images
- QR codes via GS ( k
- Code page support — CP437, Windows-1252, and more via encoding_rs
- Print density control (light to dark)
- Paper cut visualization with separator lines
- receiptio compatible — works with the receiptio CLI tool
- 100+ ESC/POS commands parsed (full list)
Installation
From crates.io
Prerequisites (Linux)
- Rust 1.73+ (for
div_ceilstabilization) - System dependencies for egui/eframe:
# Debian/Ubuntu
Build from source
The binary is at target/release/escpresso.
Usage
Start the emulator
A GUI window opens and a TCP server starts on localhost:9100.
Send ESC/POS commands
# Simple text
|
# Centered bold text
|
Use with receiptio
receiptio converts a simple text format into ESC/POS commands:
Create a receipt file (receipt.receipt):
{image:https://receiptline.github.io/receiptio/logo.png}
^^^RECEIPT
{border:line}
|Item | Price|
|Apple | $1.50|
|Orange | $2.00|
{border:space}
^^Total: $3.50
{code:https://example.com; option:qrcode,3,L}
{cut}
Send to escpresso:
|
Supported Commands
| Category | Commands |
|---|---|
| Text formatting | ESC !, ESC E, ESC -, GS !, GS B |
| Alignment | ESC a (left/center/right) |
| Position | ESC $, ESC \, ESC D (tabs) |
| Line spacing | ESC 2, ESC 3, ESC d, ESC J |
| Graphics | ESC * (bit image), GS v 0 (raster) |
| QR codes | GS ( k |
| Barcodes | GS k, GS H, GS h, GS w |
| Paper control | GS V (cut), ESC p (cash drawer) |
| Code pages | ESC t (code table selection) |
| Character sets | ESC R (international), FS commands (Kanji) |
| Initialization | ESC @, DLE commands |
See docs/COMMANDS.md for the complete list with hex codes and implementation status.
Testing
Shell tests
Shell scripts in tests/shell/ send ESC/POS command sequences via netcat:
# Start escpresso first, then in another terminal:
Rust tests
Raw file testing
The tests/raw/ directory contains binary ESC/POS captures from various sources:
|
Code Structure
The codebase is a single src/main.rs with these main components:
EscPosRenderer— The ESC/POS command parser and state machine. Processes raw bytes intoReceiptElements.ReceiptElement— Enum representing rendered items: text lines, raster images, QR codes, separators, paper cuts.PrinterState— Tracks current formatting (bold, underline, alignment, density, code page, etc.).PaperSize— 58mm or 80mm paper width configuration.- TCP server — Async Tokio listener that accepts connections and feeds data to the renderer.
- GUI — eframe/egui app that renders
ReceiptElements as a scrollable receipt preview.
About
Built by Innolabs — POS integration and Odoo specialists in Cambodia.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Ensure code passes
cargo fmt --checkandcargo clippy -- -D warnings - Add tests if applicable
- Submit a pull request