- 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
6.2 KiB
Label Printing Workflow - Corrected & Restored
📋 Complete Workflow
✅ Correct Process (Now Working)
1. File Monitoring
↓
txt file changes detected (e.g., "COM-2024-002;ART-67890;SN-20260212")
↓
2. Parse Data
↓
Split by semicolon:
- Value 1 (Article/Comanda): "COM-2024-002"
- Value 2 (Nr. Art.): "ART-67890"
- Value 3 (Serial No.): "SN-20260212"
↓
3. Load SVG Template
↓
Read: conf/label_template.svg
↓
4. Replace Variables in Template
↓
{Article} → "COM-2024-002"
{NrArt} → "ART-67890"
{Serial} → "SN-20260212"
↓
5. Convert SVG → PDF
↓
CairoSVG converts to high-quality PDF @ 1200 DPI
Saves to: pdf_backup/final_label_TIMESTAMP.pdf
↓
6. Print PDF
↓
SumatraPDF sends to configured printer
↓
7. Done! ✓
🎯 Key Features
1. Customizable Layout (SVG Template)
- Location:
conf/label_template.svg - Users can edit this file to change:
- Position of text fields
- Font size and style
- Graphics/images
- Label dimensions
- No code changes needed!
2. Variable Placeholders
The template uses curly braces for variables:
{Article}- First value (Nr. Comanda){NrArt}- Second value (Nr. Art.){Serial}- Third value (Serial No.)
User can move these anywhere in the SVG template.
3. Automatic File Monitoring
- Watches: The configured txt file
- On change: Automatically reads and prints
- No manual intervention needed
🔧 What Was Fixed
Problem 1: SVG Template Was Disabled ❌
Before: Code was using fallback PDF generation (hardcoded layout) Now: SVG template is properly enabled and used
Problem 2: Poor SVG Rendering ❌
Before: svglib was failing with many errors, causing fragmentedoutput Now: CairoSVG is used first (better font/rendering support)
Problem 3: Extra Conversion Steps ❌
Before: GhostScript was re-converting already good PDFs Now: Direct SVG → PDF → Print (no extra conversions)
📝 Data Flow Example
Input File Content:
COM-2024-002;ART-67890;SN-20260212
Parsing:
parts = text.split(';')
article = parts[0] # "COM-2024-002"
nr_art = parts[1] # "ART-67890"
serial = parts[2] # "SN-20260212"
Template Before Replacement:
<text>Nr. Comanda:{Article}</text>
<text>Nr. Art.:{NrArt}</text>
<text>Serial No.:{Serial}</text>
Template After Replacement:
<text>Nr. Comanda:COM-2024-002</text>
<text>Nr. Art.:ART-67890</text>
<text>Serial No.:SN-20260212</text>
Output:
- PDF file:
pdf_backup/final_label_20260213_HHMMSS.pdf - Print: Sent to configured printer
- Log: Entry added to
logs/print_log_20260213.csv
🎨 How to Customize the Label Layout
-
Open the template:
conf/label_template.svg -
Edit in any SVG editor:
- Inkscape (free)
- Adobe Illustrator
- CorelDRAW
- Or any text editor
-
Keep the variable placeholders:
{Article}{NrArt}{Serial}
-
Save the file
-
Next print will use the new layout!
Example Changes:
- Move text to different positions
- Change font size in the SVG
- Add company logo
- Change colors
- Adjust spacing
🚀 Testing the Workflow
Test 1: Verify Template is Used
.\venv\Scripts\python.exe label_printer_gui.py
Watch console output - should see:
Using SVG template: conf\label_template.svg
Converting SVG to PDF using CairoSVG (high quality)...
✅ PDF created from SVG template: pdf_backup\final_label_...pdf
Test 2: Check the Generated PDF
# Open latest PDF to verify content
$latest = Get-ChildItem pdf_backup\*.pdf | Sort-Object LastWriteTime -Desc | Select-Object -First 1
Start-Process $latest.FullName
Verify you see:
- ✅ Three lines of text (Nr. Comanda, Nr. Art., Serial No.)
- ✅ Values filled in correctly
- ✅ Checkmark image (if template has it)
Test 3: Print Test
Put sample data in your monitored file:
COM-TEST-001;ART-7777;SN-20260213
Should automatically print with correct values.
⚙️ Configuration Files
1. Label Template (conf/label_template.svg)
- Purpose: Defines layout, positions, fonts
- Editable: Yes - by user
- Format: SVG (XML-based vector graphics)
2. App Configuration (conf/app.conf)
- Purpose: Stores GUI settings
- Contains:
- File path to monitor
- Selected printer
- Preview settings
3. Images (conf/*.png)
- accepted.png: Checkmark/approval image (embedded in template)
- refused.png: Rejection image (if needed)
🔄 Complete Print Quality Settings
The system now maintains quality through:
- SVG Template → Vector graphics (scalable, sharp)
- CairoSVG Conversion → Renders @ 1200 DPI
- PDF Output → Uncompressed, high quality
- Printer Configuration → Set to 600 DPI minimum
- Direct Printing → No extra conversions
📊 Workflow States
| Step | Status | Output |
|---|---|---|
| File changed | ✅ Working | Triggers processing |
| Parse data | ✅ Working | Splits by ; |
| Load template | ✅ Working | Reads SVG file |
| Replace variables | ✅ Working | Substitutes {...} |
| SVG→PDF | ✅ Working | CairoSVG @ 1200 DPI |
| ✅ Working | SumatraPDF direct |
🐛 Troubleshooting
Issue: "SVG template not found"
Solution: Check that conf/label_template.svg exists
Issue: "CairoSVG conversion failed"
Solution:
.\venv\Scripts\pip.exe install --upgrade cairosvg
Issue: Wrong values printed
Solution: Verify data format in txt file: value1;value2;value3
Issue: Printer prints blank/partial
Solution: Run printer configuration:
.\configure_label_size.ps1
📖 Summary
The workflow is now fully restored and working correctly:
✅ SVG template enabled for customizable layouts
✅ Variable replacement working ({Article}, {NrArt}, {Serial})
✅ High-quality PDF generation via CairoSVG
✅ Direct printing without extra conversions
✅ User can modify template without code changes
No more hardcoded layouts!
Last Updated: February 13, 2026
Status: ✅ Workflow Restored & Working