10 KiB
Quality Recticel Print Service - Native Windows
A lightweight Windows service that provides local HTTP API for silent PDF printing from the Quality Recticel web application. This is a native PowerShell implementation with zero external dependencies.
🏗️ Technical Architecture
┌─────────────────────────────────────────────────────────────┐
│ Quality Recticel Web App │
│ (print_module.html) │
└─────────────────────┬───────────────────────────────────────┘
│ HTTP Request
▼
┌─────────────────────────────────────────────────────────────┐
│ Native PowerShell Print Service │
│ (localhost:8765) │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │
│ │ PowerShell │ │ CORS │ │ PDF Handler │ │
│ │ HTTP Server │ │ Support │ │ & WMI │ │
│ └─────────────┘ └──────────────┘ └─────────────────┘ │
└─────────────────────┬───────────────────────────────────────┘
│ Native Messaging (Optional)
▼
┌─────────────────────────────────────────────────────────────┐
│ Chrome Extension │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │
│ │ Background │ │ Content │ │ Popup │ │
│ │ Service │ │ Script │ │ UI │ │
│ │ Worker │ │ │ │ │ │
│ └─────────────┘ └──────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Overview
This service creates a local HTTP server on localhost:8765 that receives print requests from the Quality Recticel web application and handles silent PDF printing to local printers.
Key Features
- 🚀 Native Windows: Pure PowerShell implementation - no Python or external dependencies
- 🖨️ Silent Printing: Print PDFs without showing print dialogs
- 🔧 Printer Management: List and select available local printers
- ⚙️ Windows Service: Runs automatically in the background
- 🌐 Chrome Extension Integration: Works seamlessly with the Quality Recticel Chrome extension
- 📡 REST API: Simple HTTP endpoints for printing operations
- 📝 Comprehensive Logging: Detailed service logs for troubleshooting
Quick Installation
Prerequisites
- Windows 10/11 or Windows Server 2016+
- Administrator privileges
- PowerShell (included with Windows)
- Chrome browser (for the extension)
Install Steps
-
Download Service Package
- Download the complete service package from the Quality Recticel system
- Extract all files to a temporary folder
-
Run Native Installer
# Right-click and "Run as administrator" install_native_service.bat -
Install Chrome Extension
- Open Chrome and go to
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked" and select the
chrome_extensionfolder
- Open Chrome and go to
-
Test Installation
- Open your browser to: http://localhost:8765/health
- You should see a JSON response indicating the service is healthy
Service Architecture
Native PowerShell Service
- No Dependencies: Uses only built-in Windows components
- HTTP Listener: .NET HttpListener for web requests
- WMI Integration: Windows Management Instrumentation for printer access
- Service Integration: Native Windows Service Control Manager
File Structure
C:\Program Files\QualityRecticel\PrintService\
├── print_service.ps1 # Main PowerShell service script
└── print_service.log # Service activity log
API Endpoints
Health Check
GET http://localhost:8765/health
Response:
{
"status": "healthy",
"service": "Quality Recticel Print Service",
"version": "1.0",
"timestamp": "2024-01-15 14:30:25",
"platform": "Windows PowerShell"
}
List Printers
GET http://localhost:8765/printers
Response:
{
"success": true,
"printers": [
{
"name": "HP LaserJet Pro",
"driver": "HP Universal Printing PCL 6",
"port": "IP_192.168.1.100",
"is_default": true,
"status": 3
}
],
"count": 1
}
Print PDF
POST http://localhost:8765/print/pdf
POST http://localhost:8765/print/silent
Content-Type: application/json
{
"pdf_url": "https://example.com/document.pdf",
"printer_name": "HP LaserJet Pro",
"copies": 1
}
Response:
{
"success": true,
"message": "Print job sent successfully",
"printer": "HP LaserJet Pro",
"timestamp": "2024-01-15 14:30:25"
}
Service Management
Using Service Control Manager
# Start service
sc start QualityRecticelPrintService
# Stop service
sc stop QualityRecticelPrintService
# Check status
sc query QualityRecticelPrintService
# Restart service
sc stop QualityRecticelPrintService && sc start QualityRecticelPrintService
Using Services GUI
- Press
Windows + R, typeservices.msc - Find "Quality Recticel Print Service"
- Right-click for start/stop/restart options
View Logs
Service logs are automatically written to:
C:\Program Files\QualityRecticel\PrintService\print_service.log
Troubleshooting
Service Won't Start
- Check Administrator Rights: Ensure installer was run as Administrator
- PowerShell Execution Policy: Verify PowerShell execution policy allows scripts
Get-ExecutionPolicy # Should be RemoteSigned or Unrestricted - Port Conflict: Check if port 8765 is already in use
netstat -ano | findstr :8765 - Service Logs: Check the log file for detailed error messages
Printing Issues
- Printer Access: Verify printers are accessible from Windows services
- PDF Access: Ensure PDF URLs are accessible from the service context
- Print Queue: Check Windows print queue for stuck jobs
- Permissions: Verify service has permission to access printers
Chrome Extension Issues
- Service Connection: Test http://localhost:8765/health in browser
- Extension Loading: Verify extension is properly loaded in Chrome
- CORS: Service includes proper CORS headers for browser access
- Console Errors: Check browser console for JavaScript errors
Security Features
- Localhost Only: Service only accepts connections from 127.0.0.1/localhost
- No External Access: No outbound network requirements except for PDF downloads
- Temporary Files: PDF downloads are cleaned up automatically
- Service Account: Runs with minimal required privileges
- CORS Protection: Proper cross-origin resource sharing headers
Uninstallation
Automated Uninstall
# Right-click and "Run as administrator"
uninstall_service.bat
Manual Uninstall
# Stop and delete service
sc stop QualityRecticelPrintService
sc delete QualityRecticelPrintService
# Remove files (optional)
rmdir /s "C:\Program Files\QualityRecticel"
Advantages of Native Solution
✅ Zero Dependencies: No Python, Flask, or external packages required
✅ Faster Installation: No package downloads or environment setup
✅ Better Integration: Native Windows service with proper lifecycle management
✅ Smaller Footprint: Minimal disk space and memory usage
✅ Enterprise Ready: Uses only trusted Windows components
✅ Easier Deployment: Single installer with no prerequisites
Development Notes
PowerShell Service Implementation
The service uses PowerShell's built-in capabilities:
System.Net.HttpListenerfor HTTP server functionalityGet-WmiObject Win32_Printerfor printer enumerationSystem.Net.WebClientfor PDF downloads- Native Windows service architecture
Why PowerShell vs Python?
- Deployment: No need to install Python runtime or pip packages
- Security: Uses only Microsoft-signed components
- Performance: Faster startup and lower memory usage
- Maintenance: Easier to troubleshoot with native Windows tools
- Enterprise: Better compliance with corporate security policies
Support
For issues or questions:
- Check the troubleshooting section above
- Review service logs at
C:\Program Files\QualityRecticel\PrintService\print_service.log - Test individual endpoints using browser or curl
- Contact Quality Recticel IT support with log details
File Inventory
install_native_service.bat- Service installer (run as Administrator)uninstall_service.bat- Service removal scriptprint_service.ps1- Main PowerShell service implementationchrome_extension/- Chrome extension files (optional)README.md- This documentation file