Generate Code 128 barcodes from CSV data and compile them into organized PDF documents using zint and Typst
This skill helps you work with a barcode generation system that creates Code 128 barcodes from CSV data and compiles them into organized PDF documents.
The system reads CSV data, generates individual barcode PNG images using the `zint` library, and compiles them into a professionally formatted PDF using Typst. It includes automatic archiving with git versioning to track generation history.
Before using this skill, ensure these dependencies are installed:
1. **Main Script**: `barcode_gen_pdf.sh` contains the complete end-to-end workflow
2. **CSV Data Source**: `~/Laser-pou.csv` should contain your source data with:
- Column 1: Key/ID for grouping barcodes
- Columns 2-4: Data fields encoded in the barcode (tab-separated)
- Header row (automatically skipped during processing)
3. **Output Files**:
- `all_barcodes.pdf` - Latest compiled PDF (always in root directory)
- `arch/YYYY-MM-DD_HH-MM-SS/` - Timestamped archives of each generation run
4. **Barcode Naming**: Generated files follow pattern `barcode_{key}_{sequence}.png`
When modifying or troubleshooting the barcode generation:
1. **Review the workflow in `barcode_gen_pdf.sh`**:
- CSV processing with awk (reads `~/Laser-pou.csv`, skips header with `NR > 1`)
- Barcode generation with `zint -b 20` (Code 128 format)
- Dynamic Typst document generation with proper grouping
- PDF compilation
- Auto-archiving to timestamped directories
- Git versioning with descriptive commit messages
2. **CSV Format Requirements**:
- First column: Key for grouping related barcodes
- Columns 2-4: Data fields that get encoded
- Header row is automatically skipped
- Data is tab-separated when encoded into barcode
3. **PDF Layout Specifications**:
- US Letter format
- Margins: 0.75" horizontal, 1" vertical
- 14pt body text, 20pt bold headings
- Centered alignment throughout
- Page breaks between key groups
- 0.5cm spacing after headings
- 0.25cm spacing between barcode images
4. **Archive Structure**:
- Archives stored in `arch/` directory
- Each run creates timestamped subdirectory (YYYY-MM-DD_HH-MM-SS)
- Contains all PNG files and PDF copy from that generation
- Automatically committed to git with barcode count in message
**Generate barcodes and create PDF (primary workflow)**:
```bash
./barcode_gen_pdf.sh
```
**Manually compile PDF from existing Typst template**:
```bash
typst compile barcodes_example.typ all_barcodes.pdf
```
**Verify zint barcode generation format**:
```bash
zint -b 20 --data="test" -o test_barcode.png
```
When making changes to the barcode generation:
1. **Changing barcode format**: Modify the `-b` flag in zint command (currently `-b 20` for Code 128)
2. **Adjusting PDF layout**: Edit the Typst document generation section in `barcode_gen_pdf.sh`:
- Page setup: `#set page()` block
- Text formatting: `#set text()` block
- Spacing: `#v()` commands between elements
3. **Modifying data encoding**: Update the awk command that processes CSV columns
4. **Archive behavior**: Modify the archiving section (currently moves PNGs, copies PDF, and commits to git)
**If barcodes aren't generating**:
**If PDF compilation fails**:
**If archiving fails**:
```bash
./barcode_gen_pdf.sh
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/barcode-generator/raw