A lightweight HTTP print server that runs as a Windows service and accepts localhost API calls from a browser to send files to system printers.
- Windows 10/11 (x64)
- .NET 10 SDK (for building)
- Inno Setup (for creating the installer manually)
| Type | Content-Type | Print Method |
|---|---|---|
application/pdf |
SumatraPDF (Session 0 safe) | |
| PNG | image/png |
GDI+ PrintDocument |
| JPEG | image/jpeg |
GDI+ PrintDocument |
| BMP | image/bmp |
GDI+ PrintDocument |
| GIF | image/gif |
GDI+ PrintDocument |
| TIFF | image/tiff |
GDI+ PrintDocument |
| Plain text | text/plain |
GDI+ PrintDocument (Consolas 10pt, paginated) |
| ZPL | application/vnd.zebra.zpl or text/x-zpl |
Raw print via Windows spooler |
| Word | application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document |
Shell verb (interactive mode only) |
| Excel | application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
Shell verb (interactive mode only) |
Office documents (DOC/DOCX/XLS/XLSX) are only supported when running interactively (not as a Windows service). Convert to PDF first when running as a service.
The project includes a GitHub Actions workflow (.github/workflows/build.yml) that runs on every push and PR to main. It restores, builds, runs tests, publishes, and compiles the Inno Setup installer. The resulting PrintingServerSetup.exe is uploaded as a build artifact.
SumatraPDF portable is committed to the repo at PrintingServer/tools/SumatraPDF.exe and bundled automatically during publish.
- Download
PrintingServerSetup.exefrom the latest GitHub Actions run artifacts - Run the installer as administrator on the target machine
The installer will:
- Copy files to
Program Files\PrintingServer - Register and start a Windows service named
PrintingServer - The service starts automatically on boot
1. Publish
dotnet publish PrintingServer/PrintingServer.csproj -c Release -o PrintingServer/bin/publish
2. Create installer
Compile installer.iss with Inno Setup. The output installer will be in installer_output/PrintingServerSetup.exe.
3. Run the installer
Run PrintingServerSetup.exe as administrator.
Edit appsettings.json in the install directory to change the port (default 5123):
{
"PrintingServer": {
"Port": 5123
}
}Restart the service after changing configuration:
sc stop PrintingServer
sc start PrintingServer
GET http://localhost:5123/health
{ "status": "ok" }GET http://localhost:5123/printers
{
"defaultPrinter": "HP LaserJet Pro",
"printers": ["HP LaserJet Pro", "Microsoft Print to PDF", "Zebra ZD420"]
}POST http://localhost:5123/print?printer=HP%20LaserJet%20Pro&copies=2
Content-Type: application/pdf
<file bytes>
| Parameter | Required | Description |
|---|---|---|
printer |
No | Printer name. Uses default printer if omitted. |
copies |
No | Number of copies. Defaults to 1. |
Success:
{ "message": "Print job submitted.", "printer": "HP LaserJet Pro" }Error:
{ "error": "Printer 'FakePrinter' is not valid." }// Print a PDF (2 copies)
await fetch("http://localhost:5123/print?printer=HP%20LaserJet%20Pro&copies=2", {
method: "POST",
headers: { "Content-Type": "application/pdf" },
body: pdfBlob
});
// Print a PNG
await fetch("http://localhost:5123/print?printer=HP%20LaserJet%20Pro&copies=1", {
method: "POST",
headers: { "Content-Type": "image/png" },
body: pngBlob
});
// Print a JPEG
await fetch("http://localhost:5123/print?printer=HP%20LaserJet%20Pro&copies=1", {
method: "POST",
headers: { "Content-Type": "image/jpeg" },
body: jpegBlob
});
// Print a ZPL label (3 copies)
await fetch("http://localhost:5123/print?printer=Zebra%20ZD420&copies=3", {
method: "POST",
headers: { "Content-Type": "text/x-zpl" },
body: "^XA^FO50,50^ADN,36,20^FDShipping Label^FS^XZ"
});
// Print plain text
await fetch("http://localhost:5123/print?printer=HP%20LaserJet%20Pro&copies=1", {
method: "POST",
headers: { "Content-Type": "text/plain" },
body: "Pick List\n---------\nItem 1: Widget A x3\nItem 2: Widget B x1"
});
// Print a Word document (interactive mode only)
await fetch("http://localhost:5123/print?printer=HP%20LaserJet%20Pro&copies=1", {
method: "POST",
headers: { "Content-Type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
body: docxBlob
});
// Print an Excel spreadsheet (interactive mode only)
await fetch("http://localhost:5123/print?printer=HP%20LaserJet%20Pro&copies=1", {
method: "POST",
headers: { "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" },
body: xlsxBlob
});dotnet test
Run the uninstaller from Add/Remove Programs. It stops and removes the Windows service, then deletes the installed files.