The given project creates a single PDF document with employee ID cards (one employee per page) based on a pre-set ID template image, CSV file with employee information and a folder of employee photos. The ID cards will be of standard size (3.375 x 2.125 inches) with the name of the employee at the bottom-left and a photograph at the top-left.
- Creation of a PDF that contains each employee ID on a separate page.
- Templates ID design (
ute_id_template.png). - Reads employee data (name, photo path) in CSV file.
- Adds employee photos and text (name) to every ID.
- Name is placed at bottom-left and the font size is 10 points.
- Title: The title is placed at (1.7 inches x, 0.6 inches up) and has the font size 8.
- Photo will be placed at (0.37 inches x, 0.33 inches of the top) and the dimensions will be 1x1 inch.
- Python: Version 3.8 or higher
- Libraries:
reportlab: For PDF generationpillow: For image processing
- Input Files:
ute_id_template.png: ID template image (1013x638 pixels for 3.375x2.125 inches at 300 DPI)employeesData.csv: CSV file with columnsname,photo_path- Employee photos in
src/images/(e.g.,emp1.jpg,emp2.jpg,emp3.jpg,emp4.jpg)
Install dependencies via:
pip install -r requirements.txt-
Clone the Repository:
git clone https://github.com/your-username/employee_id_generator.git cd employee_id_generator -
Set Up a Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Prepare Input Files
- Place
ute_id_template.pnginsrc/. - Place employee photos (e.g.,
emp1.jpg,emp2.jpg) insrc/images/. - Create or update
src/employeesData.csvwith the following format:
name,photo_path Pavani,emp1.jpg Hrithik,emp2.jpg Diya,emp3.jpg Brian,emp4.jpg
- Place
-
Navigate to the
src/directory:cd src -
Run the script:
python main.py
-
Check the output:
- A file named
employee_cards.pdfwill be generated insrc/. - There is one ID card with the template, employee photo and name per page.
- A file named