A powerful, lightweight Electron-based desktop application that bridges your backend services with system printers. Printer Manager runs as a background service to handle printing tasks silently and efficiently.
Modern web applications often need to print documents, receipts, labels, and reports to physical printers. However, printing from web services directly to local printers is not possible due to browser security restrictions and the complexity of managing printer drivers across different systems.
Printer Manager solves this by:
- Providing a lightweight desktop agent that runs on user machines
- Accepting print requests from your backend API via HTTP or WebSocket
- Managing printer discovery and selection
- Handling multiple print formats (HTML, URLs, PDF)
- Running as a background service without requiring user interaction
- Offering user-friendly UI to configure printer preferences
- Supporting Windows auto-start for seamless deployment
✅ Background Service - Runs silently without UI unless opened by user
✅ Multiple Input Formats - Print from HTML, URLs, or PDF files
✅ Socket.IO Support - Real-time bidirectional communication with backend
✅ HTTP REST API - Simple POST endpoint for print requests
✅ Auto-Start on Boot - Optional Windows registry auto-start capability
✅ Printer Discovery - Automatically detects all connected printers
✅ Configuration Persistence - Saves backend URL and settings locally
✅ Print Optimization - Bold, sharp, visible text rendering
✅ Custom Margins - Precise control over print layout
✅ Error Handling - Detailed logging and error feedback
✅ Single Instance - Prevents multiple app instances running simultaneously
┌─────────────────────────────────────────────┐
│ Backend Service │
│ (Your API Server) │
└──────────────┬──────────────────────────────┘
│ HTTP POST /print
│ Socket.IO events
│
┌──────────────▼──────────────────────────────┐
│ Printer Manager (Electron App) │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ Express Server (localhost:3000) │ │
│ │ - HTTP print endpoint │ │
│ │ - Socket.IO server │ │
│ └─────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ Print Handler │ │
│ │ - Browser window creation │ │
│ │ - Content rendering │ │
│ │ - Printer communication │ │
│ └─────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ UI Window (Optional) │ │
│ │ - Printer selection │ │
│ │ - Configuration settings │ │
│ │ - Backend connection status │ │
│ └─────────────────────────────────────┘ │
└──────────────┬──────────────────────────────┘
│
├─→ System Printers (Windows)
└─→ Printer Drivers
- Node.js (v14 or higher)
- npm (v6 or higher)
- Windows (7 or higher) - Currently Windows-focused
-
Clone the repository
git clone <repository-url> cd printer
-
Install dependencies
npm install
-
Run in development mode
npm run dev
-
Build for production
npm run build
This creates a Windows installer in the out/ directory.
The app connects to your backend service. By default, it uses:
http://localhost:3000
To change the backend URL:
- Open the Printer Manager UI
- Go to Settings
- Enter your backend service URL (e.g.,
https://abc-api.invexone.com) - Click Save
The configuration is saved locally in your user data directory.
Enable auto-start so the app launches automatically when Windows boots:
- Open Printer Manager
- Check "Enable Auto-Start"
- The app will now start silently on every boot
To disable, uncheck the same option.
-
Install and Launch
- Run the installer
- Launch Printer Manager from Start Menu or create a shortcut
-
Configure
- Select your preferred printer from the dropdown
- Verify backend connection status
- Enable auto-start if desired
-
Send Print Jobs
- Your backend service sends print requests to this app
- The app prints to the selected printer automatically
Send a POST request to the local HTTP endpoint:
fetch('http://localhost:3000/print', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
data: '<html><body>Hello World</body></html>',
format: 'html' // 'html', 'url', or 'pdf'
})
})
.then(res => res.json())
.then(data => console.log(data));Connect to the Socket.IO server:
const io = require('socket.io-client');
const socket = io('http://localhost:3000');
socket.on('connect', () => {
console.log('Connected to Printer Manager');
// Send print request
socket.emit('print', {
data: {
data: '<html><body>Invoice #123</body></html>',
format: 'html'
}
});
});
// Listen for results
socket.on('print-result', (result) => {
if (result.success) {
console.log('Print successful:', result.message);
} else {
console.error('Print failed:', result.message);
}
});
socket.on('print-error', (error) => {
console.error('Print error:', error.message);
});{
"data": "<html><body style='font-weight:bold'>Receipt #12345</body></html>",
"format": "html"
}{
"data": "https://example.com/invoice/12345",
"format": "url"
}{
"data": "/path/to/file.pdf",
"format": "pdf"
}Description: Submit a print job
Request Body:
{
"data": "string (HTML content, URL, or file path)",
"format": "html|url|pdf"
}Response (Success):
{
"success": true,
"message": "Print sent to HP LaserJet Pro"
}Response (Error):
{
"success": false,
"message": "No printer selected. Please select a printer first."
}printers-list: List of available printersbackend-status: Connection status to backendprint-result: Result of print operationprint-error: Error during print operation
print: Submit a print job{ data: { data: "content", format: "html|url|pdf" } }
The app automatically formats all print output with:
- Bold text for maximum visibility
- Sharp rendering with antialiasing
- Custom margins (minimal top/bottom, zero left/right)
- Max width constraint (8 inches) to prevent overflow
- 70% scale factor for optimal sizing
Modify these settings in the printToSelectedPrinter() function in main.js.
printer/
├── main.js # Main Electron process
├── preload.js # Preload script for IPC security
├── setup-autostart.js # Windows auto-start handler
├── src/
│ ├── index.html # Main UI HTML
│ ├── styles/ # CSS stylesheets
│ └── scripts/ # Frontend JavaScript
├── assets/ # App icons and assets
├── forge.config.js # Electron Forge configuration
├── package.json # Dependencies and scripts
└── README.md # This file
npm run start # Start in development mode
npm run dev # Run with debugger on port 5858
npm run package # Package the app
npm run make # Create installers
npm run build # Full build: package + build info + installerEnable debug mode by running:
npm run devChrome DevTools will be available on localhost:5858
All operations are logged to the console:
- Connection status
- Printer discovery
- Print requests and results
- Error messages
- Cause: User hasn't selected a printer in the UI
- Fix: Open Printer Manager and select a printer from the dropdown
- Cause: Auto-start not enabled or registry entry corrupted
- Fix:
- Open Printer Manager
- Disable auto-start
- Re-enable auto-start
- Restart Windows
- Cause: Wrong backend URL or service not running
- Fix:
- Verify backend service is running
- Check the backend URL in settings
- Ensure network connectivity
- Cause: Scale factor or window size mismatch
- Fix: Modify
scaleFactorinprintToSelectedPrinter()function
- Cause: Printer driver not installed or printer offline
- Fix:
- Verify printer is turned on and connected
- Install/update printer drivers
- Restart Printer Manager
Located in: %APPDATA%\PrinterManager\config.json
{
"backendUrl": "http://localhost:3000"
}HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
PrinterManager = "C:\path\to\PrinterManager.exe"
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- macOS and Linux support
- Additional print formats (Excel, Word, Images)
- Print queue management
- Printer-specific settings (paper size, color mode)
- Enhanced UI (dark mode, better icons)
- Printer status monitoring
- Print history and logging
- Performance optimizations
MIT License - See LICENSE file for details
For issues, questions, or suggestions:
- Check the Troubleshooting section
- Review existing issues on GitHub
- Create a new issue with detailed information
- Include logs and error messages
- macOS support
- Linux support
- Print queue management UI
- Print job history
- Network printer detection
- Print preview functionality
- Custom print templates
- Email integration
- Cloud storage integration (Google Drive, OneDrive)
- Mobile app companion
- Advanced authentication for backend
- Memory Usage: Minimal when idle (~50-100MB)
- CPU Usage: <1% when idle, spikes only during print jobs
- Network: Only communicates with configured backend
- Startup Time: <2 seconds
- Print Time: Depends on content size and printer speed
- IPC Isolation: Uses context isolation and preload scripts
- No Admin Rights: Runs as regular user
- Local Only: Doesn't upload data to external services
- Config Encryption: User data stored locally, not synced
- CORS Enabled: Allows requests from configured origins
Q: Can I print to multiple printers?
A: Currently, only one printer can be selected at a time. Print jobs go to the selected printer.
Q: Does it work on macOS/Linux?
A: Not yet. Windows support is current. Cross-platform support is planned.
Q: Can I print without selecting a printer?
A: No. A printer must be selected before any print job can be processed.
Q: Is there a file size limit for printing?
A: No hard limit, but very large HTML/PDF files may take longer to render.
Q: Can I customize print styling?
A: Yes. Modify the CSS injected in the printToSelectedPrinter() function.
Q: Does it work offline?
A: It can print locally without backend connection, but Socket.IO features require connectivity.
Made with ❤️ for seamless printing