invoice-print-service
v1.0.5
Published
http printer service
Maintainers
Readme
HTTPService Printer
HTTPService Printer is a Node.js-based service that provides silent printing of HTML content to PDF and physical printers via a REST API. It uses Express, Puppeteer, and pdf-to-printer, and can be installed as a Windows service for always-on printing.
NPM
npm install -g invoice-print-serviceFeatures
- Exposes HTTP endpoints for printing HTML to a physical printer.
- Automatically generates PDFs and sends them to the printer.
- Supports multiple printers and settings.
- Can run as a Windows service (install/uninstall script included).
- Uses Puppeteer for rendering HTML and Chrome for PDF generation.
Install the Service
The service.js script allows you to install/uninstall the Express print service as a Windows service.
- Open a terminal in the project folder.
- Install the service:
printserver install- The service is named alen-print-service (or change the
nameinservice.js). - The service will start automatically.
- To uninstall:
printserver uninstallAPI Endpoints
GET /ping
Check if the service is online.
Response:
{
"printerIsOnline": true
}GET /printers
List available printers and the default printer.
Response Example:
[
{
"deviceId": "Printer1",
"name": "HP LaserJet",
"isDefault": true
},
{
"deviceId": "Printer2",
"name": "Canon Inkjet"
}
]POST /print
Print HTML content to a specified printer.
Request Body:
{
"deviceId": "Printer1",
"html": "<h1>Hello World</h1>",
"settings": { "format": "A4" }
}Response Example:
{
"printer": { "deviceId": "Printer1", "name": "HP LaserJet" },
"status": "printed"
}How It Works
- Receives HTML content via POST
/print. - Generates a temporary PDF using Puppeteer and Chrome.
- Sends the PDF to the selected printer using pdf-to-printer.
- Deletes the temporary PDF after printing.
- Supports queued printing via
printQueue.js.
Logging
Logs are generated using logger.js. You can customize it to output to console, files, or external logging services.
Notes
- Chrome must be installed and detected by
chrome-launcher. - Temporary PDFs are stored in the
jobs/folder inside the project directory. - The service is silent; no browser windows will open during printing (
headless: true).
