PrintGateway is a .NET print gateway service for Windows that enables document printing via REST API. Supports PDF, images, Office documents, and more, with print queue management, status tracking, and idempotency guarantees.
- 📄 Multi-format Support: PDF, Images (JPG/PNG/BMP/TIFF/GIF/WebP), Office documents (DOC/XLS/PPT)
- 🖨️ Printer Discovery: Auto-enumerates system printers with default printer selection
- 📊 Print Queue: Job status tracking (Pending → Printing → Completed/Failed)
- 💾 Persistence: SQLite-based job storage with recovery after service restart
- 🔐 Security: Optional API Token authentication with tray-managed security status
- 🔄 Idempotency: Idempotency key support to prevent duplicate printing
- 🖥️ Tray Icon: System tray monitoring with one-click service control
- 🔧 Windows Service: Installable as Windows Service with auto-start on boot
- 🌐 Web UI: Local web interface for file upload, print settings, and queue management
- Page Orientation: Auto/Portrait/Landscape
- Color Mode: Auto/Color/Grayscale
- Paper Size: Auto/A4/Letter/Legal
- .NET 10 SDK
- Windows 10/11
- LibreOffice or MS Office (optional, for Office document conversion)
# Build a local release folder and start the tray app
.\scripts\publish-release.ps1
.\Release\PrintGatewayTray\PrintGatewayTray.exeAfter startup:
- 🖥️ Access Web UI: Double-click tray icon or open browser to http://localhost:7000
- 📱 LAN Access: Enable
Allow LAN Accessfrom the tray menu, then restart the app before usinghttp://<your-ip>:7000 - 🔐 Authentication: Enable
API Tokenfrom the tray menu if remote or protected access is needed - 🛑 Stop Service: Right-click tray icon → Exit (automatically stops the service)
dotnet run --project src/PrintGatewayTrayGET /health
→ 200 { "status": "ok", "uptime": "...", "security": { "authenticationEnabled": false }, "network": { "allowLanAccess": false } }GET /api/printers
→ 200 { "printers": [{ "name": "...", "isDefault": true, "isAvailable": true }], "showVirtual": false }POST /api/jobs
Content-Type: multipart/form-data
Parameters:
- file: File (required)
- printerName: Printer name (optional)
- copies: Number of copies (optional, default 1)
- pageOrientation: Orientation (optional: Auto/Portrait/Landscape)
- colorMode: Color mode (optional: Auto/Color/Grayscale)
- paperSize: Paper size (optional: Auto/A4/Letter/Legal)
- idempotencyKey: Idempotency key (optional)
→ 202 { "jobId": "...", "status": "Pending", ... }GET /api/jobs/{id}
→ 200 { "jobId": "...", "status": "Completed", ... }DELETE /api/jobs/{id}
→ 200 { "jobId": "...", "status": "Cancelled" }- Local Access: Double-click system tray icon or open browser to http://localhost:7000
- LAN Access: Access
http://<your-ip>:7000from other devices
LAN access is disabled by default. Enable it from the tray menu and restart the application before testing from another device.
- 📤 Upload Files: Drag and drop files to upload area, or click to select
- Supported formats: PDF, JPG, PNG, BMP, TIFF, GIF, WebP, DOC, DOCX, PPT, PPTX, XLS, XLSX
- Supports multi-file batch upload
- ⚙️ Print Settings:
- Printer selection
- Number of copies (1-99)
- Page orientation (Auto/Portrait/Landscape)
- Color mode (Auto/Color/Grayscale)
- Paper size (Auto/A4/Letter/Legal)
- Virtual printer visibility (configured via
ShowVirtualPrintersin appsettings)
- 📋 Print Queue: Real-time display of print job status with cancel support
- Pending (Yellow)
- Printing (Blue)
- Completed (Green)
- Failed (Red)
- API authentication is optional. When enabled, send
X-API-TokenorAuthorization: Bearer <token>with all/api/*requests. - LAN access is disabled by default. After enabling it in the tray menu, open port 7000 in Windows Firewall if remote devices must connect:
# Run as Administrator
New-NetFirewallRule -DisplayName "PrintGateway" -Direction Inbound -LocalPort 7000 -Protocol TCP -Action AllowPrintGateway provides an MCP (Model Context Protocol) server that allows AI assistants to directly use printing capabilities:
cd skills/print-gateway-skill
pip install -r requirements.txt
python mcp_server.pyAdd the MCP server to your openclaw configuration to use the print tool.
See: skills/print-gateway-skill/README.md
dotnet test# v1 Test (PDF printing)
.\scripts\openclaw-print-test.ps1
# v2 Test (Multi-format + print options)
.\scripts\openclaw-v2-print-test.ps1Edit src/PrintGateway/appsettings.json:
{
"PrintGateway": {
"DefaultPrinter": "Your Printer Name",
"MaxFileSizeMB": 50,
"JobRetentionHours": 168,
"ShowVirtualPrinters": false
},
"Network": {
"AllowLanAccess": false
},
"Security": {
"ApiToken": ""
},
"ConnectionStrings": {
"JobsDb": "Data Source=data/jobs.db"
}
}print_service/
├── src/
│ ├── PrintGateway/ # Core service
│ │ ├── Models/ # Data models
│ │ ├── Services/ # Business logic
│ │ │ └── Converters/ # Document converters
│ │ ├── Middleware/ # Middleware
│ │ ├── Endpoints/ # API endpoints
│ │ └── wwwroot/ # Web UI static files
│ │ ├── index.html # Main page
│ │ ├── css/style.css # Styles
│ │ └── js/app.js # Frontend logic
│ │ └── js/i18n.js # Internationalization
│ └── PrintGatewayTray/ # Tray application
├── tests/
│ └── PrintGateway.Tests/ # Unit tests
├── scripts/ # PowerShell scripts
├── skills/ # OpenClaw Skill
│ └── print-gateway-skill/
├── testdata/ # Test data
├── data/ # Runtime data (jobs.db, logs)
├── PrintGatewayManager.ps1 # Management script
└── PrintGateway.sln # Solution file
| Type | Extensions | Notes |
|---|---|---|
.pdf |
Native support | |
| Images | .jpg, .jpeg, .png, .bmp, .tiff, .tif, .gif, .webp |
Converted to PDF for printing |
| Office | .doc, .docx, .ppt, .pptx, .xls, .xlsx |
Requires LibreOffice |
# Check port usage
netstat -ano | findstr :7000
# View logs
Get-Content src\PrintGateway\logs\printgateway-*.log -Tail 50Ensure LibreOffice is installed and added to system PATH:
# Check LibreOffice
where soffice# Restart tray application
.\PrintGatewayManager.ps1 -Action restart- Check printer physical connection and power
- Verify printer is set as online in Windows Devices and Printers
- Jobs will queue automatically and print when printer comes back online
Issues and Pull Requests are welcome!
MIT License - See LICENSE for details.
Thanks to all contributors!