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
This commit is contained in:
296
old_code/DOTTED_TEXT_SOLUTION.md
Normal file
296
old_code/DOTTED_TEXT_SOLUTION.md
Normal file
@@ -0,0 +1,296 @@
|
||||
# Print Quality Issue - Dotted/Pixelated Text Solution
|
||||
|
||||
## 🔍 Problem Identified
|
||||
|
||||
**Issue:** Text appears dotted/pixelated on printed labels (like dot-matrix printer output)
|
||||
- PDF looks perfect on screen ✅
|
||||
- But printed output has dotted text ❌
|
||||
- Not smooth/sharp like expected
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Root Cause
|
||||
|
||||
The problem is in the **print pipeline**, not the PDF:
|
||||
|
||||
1. **PDF is generated correctly** at 1200 DPI with vector fonts
|
||||
2. **Printing process rasterizes** (converts to bitmap) the PDF
|
||||
3. **Rasterization happens at LOW resolution** (150-300 DPI typically)
|
||||
4. **Result:** Dotted text instead of smooth vectors
|
||||
|
||||
### Why This Happens:
|
||||
|
||||
```
|
||||
PDF (Vector) → SumatraPDF → Low DPI Raster → Printer Driver → Dotted Output
|
||||
↑ Problem here! Converts to low-res bitmap
|
||||
```
|
||||
|
||||
The printer receives a **bitmap image** at low resolution, not the original vector graphics.
|
||||
|
||||
---
|
||||
|
||||
## ✅ Solutions Implemented
|
||||
|
||||
### **Solution 1: Printer Quality Configuration (CRITICAL)**
|
||||
|
||||
Updated `print_label.py` to configure printer for HIGH QUALITY before printing:
|
||||
|
||||
```python
|
||||
# New function: configure_printer_quality()
|
||||
- Sets PrintQuality = 600 DPI (not draft mode)
|
||||
- Sets TTOption = DMTT_BITMAP (sharper text)
|
||||
- Configures paper size to 35mm x 25mm
|
||||
```
|
||||
|
||||
**This is now automatic** - runs before every print job.
|
||||
|
||||
---
|
||||
|
||||
### **Solution 2: GhostScript Printing (BEST QUALITY)**
|
||||
|
||||
Added GhostScript as primary printing method:
|
||||
|
||||
**Why GhostScript is Better:**
|
||||
- ✅ Maintains **vector graphics** (not rasterized)
|
||||
- ✅ Renders directly to printer at **1200 DPI**
|
||||
- ✅ Perfect text anti-aliasing
|
||||
- ✅ No intermediate bitmap conversion
|
||||
|
||||
**Printing Priority:**
|
||||
1. **GhostScript** (if installed) - BEST quality
|
||||
2. SumatraPDF (fallback) - Good quality
|
||||
3. ShellExecute (fallback) - Uses default PDF viewer
|
||||
4. Open file (last resort) - Manual printing
|
||||
|
||||
---
|
||||
|
||||
## 🚀 How to Get Best Quality
|
||||
|
||||
### **Option A: Install GhostScript (Recommended)**
|
||||
|
||||
1. **Download GhostScript:**
|
||||
- Go to: https://ghostscript.com/releases/gsdnld.html
|
||||
- Download: "GPL Ghostscript 10.04.0 for Windows (64 bit)"
|
||||
|
||||
2. **Install:**
|
||||
- Run installer
|
||||
- Use default installation path
|
||||
- No special configuration needed
|
||||
|
||||
3. **Test:**
|
||||
```powershell
|
||||
python print_pdf_ghostscript.py
|
||||
```
|
||||
Should show: ✅ GhostScript found
|
||||
|
||||
4. **Print:**
|
||||
- Just run your GUI normally
|
||||
- It will automatically use GhostScript
|
||||
- You'll see: "Using GhostScript for high-quality vector printing..."
|
||||
|
||||
**Result:** Perfect, sharp text with no dotting!
|
||||
|
||||
---
|
||||
|
||||
### **Option B: Configure Printer (Without GhostScript)**
|
||||
|
||||
If you can't install GhostScript, the code now **automatically** configures printer quality.
|
||||
|
||||
But you should also manually check:
|
||||
|
||||
1. **Open Printer Preferences:**
|
||||
```powershell
|
||||
.\configure_label_size.ps1
|
||||
```
|
||||
|
||||
2. **Set Quality to HIGHEST:**
|
||||
- Look for "Print Quality" or "Resolution"
|
||||
- Set to: **600 DPI** or **Best** or **High Quality**
|
||||
- NOT "Draft" or "Normal" or "Economy"
|
||||
|
||||
3. **Disable Dithering:**
|
||||
- Look for "Dithering" or "Halftone"
|
||||
- Set to: **None** or **Off**
|
||||
|
||||
4. **Set Graphics Mode:**
|
||||
- Look for "Graphics" or "Text Quality"
|
||||
- Set to: **Vector** or **High Quality**
|
||||
|
||||
---
|
||||
|
||||
## 📊 Quality Comparison
|
||||
|
||||
| Method | Text Quality | Speed | Installation |
|
||||
|--------|--------------|-------|--------------|
|
||||
| **GhostScript** | ⭐⭐⭐⭐⭐ Perfect | Fast | Requires install |
|
||||
| **SumatraPDF + Quality Config** | ⭐⭐⭐⭐ Very Good | Fast | No install needed |
|
||||
| **SumatraPDF (default)** | ⭐⭐ Dotted | Fastest | No install needed |
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
### Test 1: Check Current Method
|
||||
```powershell
|
||||
# Start GUI
|
||||
.\venv\Scripts\python.exe label_printer_gui.py
|
||||
|
||||
# Watch console output:
|
||||
# Should say one of:
|
||||
# "Using GhostScript for high-quality vector printing..." ← BEST
|
||||
# "Label sent to printer via SumatraPDF..." ← OK
|
||||
```
|
||||
|
||||
### Test 2: Verify GhostScript
|
||||
```powershell
|
||||
python print_pdf_ghostscript.py
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
✅ GhostScript found at: C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe
|
||||
GhostScript is available for high-quality PDF printing
|
||||
```
|
||||
|
||||
### Test 3: Print Test Label
|
||||
```powershell
|
||||
python test_quality.py
|
||||
```
|
||||
|
||||
Check printed output:
|
||||
- ✅ Text should be **smooth and sharp**
|
||||
- ✅ No dotted appearance
|
||||
- ✅ Crisp edges on checkmark image
|
||||
- ✅ Professional quality
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Troubleshooting
|
||||
|
||||
### Still seeing dotted text?
|
||||
|
||||
#### Check 1: Printer Driver Quality
|
||||
```powershell
|
||||
# Run configuration script
|
||||
.\configure_printer_quality.ps1
|
||||
|
||||
# Manually verify:
|
||||
# Settings > Printers > Labels > Printing preferences
|
||||
# Quality = HIGHEST (600 DPI or more)
|
||||
```
|
||||
|
||||
#### Check 2: Print Method Used
|
||||
Look at console output when printing:
|
||||
- **GOOD:** "Using GhostScript..."
|
||||
- **OK:** "Printer configured: 35x25mm @ HIGH QUALITY"
|
||||
- **BAD:** "Could not configure printer quality"
|
||||
|
||||
If you see "Could not configure printer quality":
|
||||
- Printer driver doesn't support programmatic quality changes
|
||||
- MUST configure manually in printer preferences
|
||||
|
||||
#### Check 3: Label Material
|
||||
- **Wrong:** Plain paper (not designed for thermal printing)
|
||||
- **Right:** Thermal labels (heat-sensitive or transfer)
|
||||
|
||||
Wrong label material can cause poor quality even with correct settings.
|
||||
|
||||
#### Check 4: Printer Hardware
|
||||
```powershell
|
||||
# Print self-test from printer
|
||||
# (Usually hold button while powering on)
|
||||
```
|
||||
|
||||
If self-test also shows dotted text:
|
||||
- Printer may be in draft mode
|
||||
- Check printer's physical control panel
|
||||
- Look for "Quality" or "Darkness" dial/setting
|
||||
- May need firmware update
|
||||
|
||||
---
|
||||
|
||||
## 📝 Technical Details
|
||||
|
||||
### Why Dotted Text Happens:
|
||||
|
||||
**Normal printing workflow:**
|
||||
```
|
||||
PDF → Printer Driver → Sharp output
|
||||
```
|
||||
|
||||
**What was happening:**
|
||||
```
|
||||
PDF (vector, 1200 DPI)
|
||||
↓
|
||||
SumatraPDF rasterizes at LOW DPI (150-300)
|
||||
↓
|
||||
Bitmap sent to printer
|
||||
↓
|
||||
Printer prints bitmap → DOTTED TEXT
|
||||
```
|
||||
|
||||
**What we fixed:**
|
||||
```
|
||||
Method 1 (GhostScript):
|
||||
PDF (vector) → GhostScript → Printer @ 1200 DPI → SHARP TEXT
|
||||
|
||||
Method 2 (Quality Config):
|
||||
PDF → Configure printer to 600 DPI → SumatraPDF → Better quality
|
||||
```
|
||||
|
||||
### Key Settings:
|
||||
|
||||
1. **PrintQuality = 600**: Tells Windows to render at 600 DPI minimum
|
||||
2. **TTOption = 2 (DMTT_BITMAP)**: Renders TrueType fonts as graphics (sharper)
|
||||
3. **GhostScript -r1200**: Renders PDF at full 1200 DPI resolution
|
||||
4. **TextAlphaBits=4**: Anti-aliasing for smooth text edges
|
||||
|
||||
---
|
||||
|
||||
## 🎓 Recommendations
|
||||
|
||||
### For Production Use:
|
||||
|
||||
1. **Install GhostScript** on all computers
|
||||
- One-time setup
|
||||
- Always best quality
|
||||
- No manual configuration needed
|
||||
|
||||
2. **Keep PDF backup enabled**
|
||||
- Review PDFs to confirm they look correct
|
||||
- PDFs are always high quality
|
||||
|
||||
3. **Test periodically**
|
||||
- Print quality can change after:
|
||||
- Windows updates
|
||||
- Driver updates
|
||||
- Printer hardware changes
|
||||
|
||||
---
|
||||
|
||||
## 📞 Quick Reference
|
||||
|
||||
### If text is dotted:
|
||||
```powershell
|
||||
# 1. Install GhostScript (best solution)
|
||||
# Download from: https://ghostscript.com/releases/gsdnld.html
|
||||
|
||||
# 2. Or configure printer manually
|
||||
.\configure_label_size.ps1
|
||||
# Set quality to HIGHEST
|
||||
|
||||
# 3. Test
|
||||
python test_quality.py
|
||||
```
|
||||
|
||||
### Check print method:
|
||||
```powershell
|
||||
# Look for this in console output:
|
||||
"Using GhostScript..." # ← You have best quality!
|
||||
"Printer configured: 35x25mm @ HIGH QUALITY" # ← Good
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** February 13, 2026
|
||||
**Status:** Multiple solutions implemented - GhostScript recommended for best quality
|
||||
Reference in New Issue
Block a user