A lightweight Windows middleware that receives pre-rendered print-ready HTML from Frappe/ERPNext via Socket.IO, converts it to PDF, and silently prints to the designated local printers.
ERPNext (Sales Invoice Submit)
└─► Frappe app renders HTML using chosen Print Format (server-side)
└─► Socket.IO event → sends { html, printer, invoice_name, … }
└─► This Windows app receives the event
└─► wkhtmltopdf converts HTML → PDF
└─► SumatraPDF silently prints to local printer
All HTML rendering and template logic lives in the Frappe app (local_printers).
The Windows app is a thin print client — it only converts HTML to PDF and prints.
- Python 3.10+
- Windows OS (uses
win32print) - SumatraPDF (silent PDF printing)
- wkhtmltopdf (HTML → PDF conversion)
- Frappe/ERPNext with the
local_printersapp installed
git clone https://github.com/Ahmed-Mansy-Mansico/local_printers_winapp.git
cd local_printers_winapp
pip install -r requirements.txtCopy config copy.json to config.json and fill in your values:
{
"FRAPPE_SOCKET_URL": "https://your-site.com",
"LOGIN_URL": "https://your-site.com/api/method/login",
"AUTH_DATA": {
"usr": "your-username",
"pwd": "your-password"
},
"API_KEY": "your-api-key",
"API_SECRET": "your-api-secret",
"WKHTMLTOPDF": "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe",
"SUMATRA_PDF_PATH": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe"
}| Key | Description |
|---|---|
FRAPPE_SOCKET_URL |
Your ERPNext site URL |
LOGIN_URL |
Login endpoint (usually {site}/api/method/login) |
AUTH_DATA |
Credentials for Socket.IO session |
API_KEY / API_SECRET |
API token for printer registration |
WKHTMLTOPDF |
Path to wkhtmltopdf.exe |
SUMATRA_PDF_PATH |
Path to SumatraPDF.exe |
python socket_app.pyThe app will:
- Load config and log in to your Frappe site
- Connect via Socket.IO and register local printers
- Listen for
sales_invoice_submittedevents - Convert received HTML to PDF and print silently
In ERPNext, go to Printer Item Group and configure:
- POS Profile — which POS triggers this printer
- Printer — the local printer name (auto-discovered)
- Print Format — choose which Print Format to render (Link field)
- No Letterhead — skip letterhead if needed
- Item Groups — route specific item categories to this printer
The Frappe app renders the full HTML using frappe.get_print() with your chosen
Print Format and sends it to this Windows app ready to print.
| Issue | Solution |
|---|---|
| Connection failures | Check config.json URL and credentials |
| No printers detected | Verify printers are installed locally |
| PDF generation fails | Check wkhtmltopdf path and installation |
| Silent print fails | Check SumatraPDF path and printer name |
- local_printers — Frappe app for ERPNext integration
MIT License