ESC/POS virtual printer emulator built in Rust
Transform your computer into a virtual receipt printer for testing and development
| Width | Characters | Dots | Use Case |
|---|---|---|---|
| 50mm | 48 chars | 384 dots | Small receipts, tickets |
| 78mm | 72 chars | 576 dots | Standard receipts |
| 80mm | 80 chars | 640 dots | Large receipts, invoices |
- Rust 1.70+ - Install Rust
- Windows 10/11 or Linux with CUPS
- Administrator privileges (for printer installation)
-
Clone the repository
git clone https://github.com/your-username/escpos-virtual-printer-emulator.git cd escpos-virtual-printer-emulator -
Build the project
cargo build --release
-
Run the emulator
cargo run --release
-
Install virtual printer
- Go to Settings tab
- Click "🖨️ Install Windows Printer" (requires admin)
- The printer will appear in Windows "Devices and Printers"
- Start the emulator - The GUI will open with the server running on port 9100
- Install the printer - Use the Settings tab to install the virtual printer
- Print from any application - Select "ESC_POS_Virtual_Printer" as your printer
- View results - Check the Receipt tab for live preview
| Command | Description | Example |
|---|---|---|
ESC @ |
Initialize printer | \x1B@ |
ESC M n |
Select font | \x1BM0 (Font A) |
ESC a n |
Justification | \x1Ba1 (Center) |
ESC E |
Emphasis (Bold) | \x1BE |
ESC - n |
Underline | \x1B-1 |
ESC 4 |
Italic | \x1B4 |
ESC 3 n |
Line height | \x1B324 |
ESC ! n |
Font size | \x1B!16 |
ESC m |
Cut paper | \x1Bm |
escpos_emulator/
├── src/
│ ├── main.rs # Application entry point
│ ├── lib.rs # Library exports
│ ├── escpos/ # ESC/POS command handling
│ │ ├── commands.rs # Command definitions
│ │ ├── parser.rs # Command parsing
│ │ └── printer.rs # Printer state management
│ ├── emulator/ # Core emulator logic
│ │ └── mod.rs # Emulator state
│ ├── networking/ # Network server
│ │ └── server.rs # TCP server implementation
│ └── gui/ # User interface
│ ├── app.rs # Main application
│ ├── receipt_viewer.rs # Receipt display
│ ├── command_log.rs # Command monitoring
│ └── settings_panel.rs # Settings and printer management
├── Cargo.toml # Project configuration
└── README.md # This file
# Development build
cargo build
# Release build (optimized)
cargo build --release
# Run tests
cargo test
# Check code
cargo check- eframe/egui - Modern GUI framework
- tokio - Async runtime and networking
- serde - Serialization/deserialization
- image - Image processing
- tracing - Structured logging
- anyhow/thiserror - Error handling
This project is licensed under the MIT License - see the LICENSE file for details.