Metadata-Version: 2.4
Name: nimilappugen
Version: 0.5.0
Summary: Generate printable nametags with barcodes from Excel/CSV data
License-Expression: MIT-0
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: openpyxl
Requires-Dist: Pillow
Requires-Dist: python-barcode
Dynamic: license-file

# NimiLappuGen

**NimiLappuGen** is a tool designed to generate printable nametags. It allows users to create print-ready nametags of any specified dimension, displaying the person's forenames and surname on separate lines, a 5-digit barcode, and customizable background graphics.

## Key Features

- **Two-Line Personalized Names:** Clearly displays the forenames and surname of the person on separate lines, with auto-scaling fonts to ensure names fit neatly.
- **Optional Subchapter:** Text for a role or group can be provided to automatically neatly fit below the person's name and above the barcode.
- **Adjustable Header Text:** Includes a small top-left header text (defaults to *"Kevätkokous Jyväskylässä 10.-12.4.2026"*).
- **Excel and CSV Data Import:** Seamlessly read lists of names (`forenames`, `surname`) and their corresponding 5-digit numbers (`number`) directly from an Excel spreadsheet or CSV file.
- **Custom Nametag Sizes:** Define the exact width and height for your nametags to fit any standard or custom badge holder.
- **5-Digit Barcodes:** Automatically generates a barcode for each nametag based on a unique 5-digit number, ideal for event registration, tracking, or access control.
- **Customizable Background Graphics:** Apply your own graphic designs, logos, or event branding as the background for the nametags.
- **Print-Ready Output:** Easily export the generated nametags into a printable format (e.g., PDF or an image grid).

## Planned Usage

1. **Provide Background Art:** Select an image file to serve as the background template (default `assets/dummy_bg.jpg`).
2. **Define Dimensions:** Input your target width and height for the printed nametag (defaults to `1000x600`).
3. **Input Data:** Provide an Excel sheet or a CSV file containing `forename`/`first`, `surname`/`last`, `subchapter`/`rooli`, and `number`/`id` columns.
4. **Generate:** The program outputs the final printable artifact combining the background, the generated barcode, and the individual's name formatted correctly.

## Usage

### Simple Usage without installing
```
uvx nimilappugen --data names.csv --pdf
```

### Install Requirements
```bash
# 1. Create a virtual environment
python -m venv venv

# 2. Activate it (Windows)
venv\Scripts\activate
# 2. Activate it (Mac/Linux)
# source venv/bin/activate

# 3. Install dependencies
pip install -r requirements.txt
```

### Basic Usage

To generate individual PNGs for each nametag listed in your data file:
```bash
python generate.py --data data.csv
```

### Generate a Printable PDF Grid

To automatically arrange the output nametags onto an A4 PDF for printing:
```bash
python generate.py --data data.csv --pdf
```

### Creating Test Samples

If you just want to test out dimensions, font scaling, or backgrounds without providing a valid data file, the generator will automatically produce 50 test samples and optionally arrange them into a PDF:
```bash
python generate.py --data missing_file.csv --pdf
```

Available arguments:
- `--data` / `-d` / `--excel` / `-e`: Path to Excel or CSV file.
- `--bg` / `-b`: Path to background image.
- `--header`: Small header text for the upper-left corner (defaults to "Kevätkokous Jyväskylässä 10.-12.4.2026").
- `--width` / `-W`: Width of the generated nametags.
- `--height` / `-H`: Height of the generated nametags.
- `--font` / `-f`: Path to a custom `.ttf` font file (falls back to system fonts automatically).
- `--pdf`: Flag to create an A4 PDF grid.
- `--pdf-name`: Output filename for the PDF (defaults to `nametags_print.pdf`).
- `--output-dir` / `-o`: Output folder (defaults to `output/`).
