This project generates a PDF file containing custom ID cards for employees. Each ID card includes the employee's photo and name, overlaid on a pre-defined ID template.
- Python 3
- Pillow (PIL Fork)
- ReportLab
To install the required Python packages, run:
pip install pillow reportlab
template.png: A pre-defined ID template image (PNG format).employee_data.csv: A CSV file containing employee details with the columns:nameandphoto.photos/: A folder containing all employee ID photos referenced in the CSV file.
-
Place the following in the same directory:
template.pngemployee_data.csvphotos/folder with all employee imagesgenerate_id_cards.pyscript
-
Run the script with:
python generate_id_cards.py
- The script will generate a PDF named
employee_id_cards.pdfin the current directory, with one ID card per employee listed in the CSV file.
- You can modify the font size and font path by editing the
setFont()line andfont_pathvariable in the script. - The positions for the photo and name placement can also be adjusted using the
photo_x,photo_y, anddrawCentredString()parameters.
- The output PDF will have the size of a standard credit card (85.6mm × 54mm), with each page containing one ID card.