Files
adaptronic_label-printer/old_code/configure_printer_quality.ps1
NAME 6a11cf3d8d Clean repository and update .gitignore
- Remove build artifacts from git tracking (build/, dist/, __pycache__/, *.spec)
- Updated .gitignore to properly exclude generated files
- Added old_code/ documentation folder
- Updated sample_data.txt to show new 5-field format
- Exclude user-specific conf/app.conf from tracking
2026-02-13 23:41:34 +02:00

226 lines
9.9 KiB
PowerShell

# Enhanced Printer Quality Configuration Script
# This script checks and optimizes printer settings for high-quality label printing
$printerName = "Labels"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Label Printer Quality Configuration" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Check if running as Administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "⚠️ Warning: Not running as Administrator" -ForegroundColor Yellow
Write-Host "Some settings may require Administrator privileges" -ForegroundColor Yellow
Write-Host ""
}
# Get printer object
$printer = Get-Printer -Name $printerName -ErrorAction SilentlyContinue
if ($null -eq $printer) {
Write-Host "❌ ERROR: Printer '$printerName' not found!" -ForegroundColor Red
Write-Host ""
Write-Host "Available printers:" -ForegroundColor Yellow
Get-Printer | ForEach-Object { Write-Host " - $($_.Name)" }
Write-Host ""
Write-Host "Please check printer name and try again." -ForegroundColor Yellow
exit 1
}
# Display printer information
Write-Host "✅ Printer Found" -ForegroundColor Green
Write-Host "Name: $($printer.Name)" -ForegroundColor White
Write-Host "Driver: $($printer.DriverName)" -ForegroundColor White
Write-Host "Port: $($printer.PortName)" -ForegroundColor White
Write-Host "Status: $($printer.PrinterStatus)" -ForegroundColor White
Write-Host ""
# Get current print configuration
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Current Print Configuration" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
try {
$printerConfig = Get-PrintConfiguration -PrinterName $printerName
$qualityText = switch ($printerConfig.PrintQuality) {
1 { "Draft (Low)" }
2 { "Normal" }
3 { "Better" }
4 { "Best (High)" }
default { "Unknown ($($printerConfig.PrintQuality))" }
}
Write-Host "Print Quality: $qualityText" -ForegroundColor $(if ($printerConfig.PrintQuality -eq 4) { "Green" } else { "Yellow" })
Write-Host "Color Mode: $($printerConfig.Color)" -ForegroundColor White
Write-Host "Duplex Mode: $($printerConfig.DuplexingMode)" -ForegroundColor White
Write-Host "Collate: $($printerConfig.Collate)" -ForegroundColor White
Write-Host ""
} catch {
Write-Host "⚠️ Could not retrieve print configuration: $_" -ForegroundColor Yellow
Write-Host ""
}
# Get printer driver properties
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Printer Properties & Capabilities" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
try {
$printerProperties = Get-PrinterProperty -PrinterName $printerName
if ($printerProperties.Count -gt 0) {
$printerProperties | ForEach-Object {
Write-Host "$($_.PropertyName): $($_.Value)" -ForegroundColor Gray
}
} else {
Write-Host "No additional properties found" -ForegroundColor Gray
}
Write-Host ""
} catch {
Write-Host "⚠️ Could not retrieve printer properties: $_" -ForegroundColor Yellow
Write-Host ""
}
# Recommendations
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Quality Recommendations" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "For optimal label printing quality:" -ForegroundColor White
Write-Host ""
Write-Host "✓ Print Quality: Set to BEST/HIGHEST (4)" -ForegroundColor Green
Write-Host "✓ DPI: 600 DPI or higher" -ForegroundColor Green
Write-Host "✓ Print Speed: Medium to Slow (quality over speed)" -ForegroundColor Green
Write-Host "✓ Darkness/Density: Medium-High (adjust for label material)" -ForegroundColor Green
Write-Host "✓ Dithering: Disabled (for sharp text/barcodes)" -ForegroundColor Green
Write-Host "✓ Graphics Mode: Vector or High Quality" -ForegroundColor Green
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Configuration Steps" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "To configure manually:" -ForegroundColor Yellow
Write-Host "1. Open: Settings > Devices > Printers & scanners" -ForegroundColor White
Write-Host "2. Click: '$printerName' > Manage" -ForegroundColor White
Write-Host "3. Click: 'Printing preferences'" -ForegroundColor White
Write-Host "4. Configure quality settings as recommended above" -ForegroundColor White
Write-Host "5. Click: Apply > OK" -ForegroundColor White
Write-Host ""
# Attempt automatic configuration
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Automatic Configuration" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Would you like to apply recommended settings automatically? (Y/N)" -ForegroundColor Yellow
$response = Read-Host
if ($response -eq 'Y' -or $response -eq 'y') {
Write-Host ""
Write-Host "Applying settings..." -ForegroundColor Cyan
$settingsApplied = $false
$errors = @()
# Try to set print quality to high (4 = Best)
try {
Set-PrintConfiguration -PrinterName $printerName -PrintQuality 4 -ErrorAction Stop
Write-Host "✅ Print quality set to BEST (4)" -ForegroundColor Green
$settingsApplied = $true
} catch {
$errors += "Print Quality: $_"
Write-Host "⚠️ Could not set print quality: $_" -ForegroundColor Yellow
}
# Try to disable duplexing for labels
try {
Set-PrintConfiguration -PrinterName $printerName -DuplexingMode OneSided -ErrorAction Stop
Write-Host "✅ Duplex mode set to One-Sided" -ForegroundColor Green
$settingsApplied = $true
} catch {
$errors += "Duplex Mode: $_"
Write-Host "⚠️ Could not set duplex mode: $_" -ForegroundColor Yellow
}
# Try to enable collation
try {
Set-PrintConfiguration -PrinterName $printerName -Collate $true -ErrorAction Stop
Write-Host "✅ Collation enabled" -ForegroundColor Green
$settingsApplied = $true
} catch {
$errors += "Collation: $_"
Write-Host "⚠️ Could not set collation: $_" -ForegroundColor Yellow
}
Write-Host ""
if ($settingsApplied) {
Write-Host "✅ Settings applied successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Note: Some printer-specific settings (DPI, darkness, etc.)" -ForegroundColor Yellow
Write-Host "must be configured through the printer preferences dialog." -ForegroundColor Yellow
} else {
Write-Host "❌ Could not apply automatic settings" -ForegroundColor Red
Write-Host ""
Write-Host "Reasons:" -ForegroundColor Yellow
foreach ($err in $errors) {
Write-Host " - $err" -ForegroundColor Gray
}
Write-Host ""
Write-Host "Please configure manually through printer preferences." -ForegroundColor Yellow
}
} else {
Write-Host ""
Write-Host "Automatic configuration skipped." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Testing Recommendations" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "After configuration, test with:" -ForegroundColor White
Write-Host "1. Print a test label from the application" -ForegroundColor White
Write-Host "2. Check text clarity and barcode scanning" -ForegroundColor White
Write-Host "3. Adjust darkness if needed:" -ForegroundColor White
Write-Host " - Too light: Increase darkness/temperature" -ForegroundColor White
Write-Host " - Too dark: Decrease darkness/temperature" -ForegroundColor White
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Additional Resources" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "📄 See: PRINT_QUALITY_IMPROVEMENTS.md" -ForegroundColor White
Write-Host " For detailed quality enhancement information" -ForegroundColor Gray
Write-Host ""
Write-Host "🔧 Printer Driver: $($printer.DriverName)" -ForegroundColor White
Write-Host " Check manufacturer website for latest updates" -ForegroundColor Gray
Write-Host ""
# Check for common thermal printer brands and provide specific guidance
$driverLower = $printer.DriverName.ToLower()
if ($driverLower -match "zebra") {
Write-Host "📌 Zebra Printer Detected" -ForegroundColor Cyan
Write-Host " Recommended: Set darkness to 15-25 (0-30 scale)" -ForegroundColor Gray
Write-Host " Access via: Preferences > Advanced > Darkness" -ForegroundColor Gray
Write-Host ""
} elseif ($driverLower -match "dymo") {
Write-Host "📌 Dymo Printer Detected" -ForegroundColor Cyan
Write-Host " Recommended: Set quality to 'High Quality'" -ForegroundColor Gray
Write-Host " Access via: Preferences > Quality tab" -ForegroundColor Gray
Write-Host ""
} elseif ($driverLower -match "brother") {
Write-Host "📌 Brother Printer Detected" -ForegroundColor Cyan
Write-Host " Recommended: Set resolution to highest available" -ForegroundColor Gray
Write-Host " Access via: Printing Preferences > Advanced" -ForegroundColor Gray
Write-Host ""
}
Write-Host "Press any key to exit..." -ForegroundColor DarkGray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")