😫 Vấn đề (The Pain Point)
Bạn có mẫu “Đơn đăng ký” (PDF Form). Có 100 nhân viên cần điền đơn này. Bạn có danh sách thông tin trong Excel. Chẳng lẽ mở file PDF lên, copy tên từng người paste vào?
🚀 Giải pháp Agentic (The Solution)
Tool “Mail Merge” cho PDF. Đọc dữ liệu Excel và điền vào đúng vị trí Form Field trong PDF.
Tính năng:
- Field Mapping: Khớp cột “Họ tên” trong Excel với field “Full_Name” trong PDF.
- Batch Fill: Tạo ra 100 file PDF đã điền sẵn thông tin trong tích tắc.
🤖 Engineering Prompt (Copy & Paste)
**Role:** Python Automation Developer
**Task:** Create a "Bulk PDF Form Filler".
**Requirements:**
1. **Tech Stack:** Python, `tkinter`, `pypdf` (supports form filling), `pandas`.
2. **Prerequisite:** The Input PDF must be a "Fillable Form" (created in Acrobat/Word).
3. **GUI:**
* Select Template PDF (Form).
* Select Data Source (Excel/CSV).
* **Mapping Interface (Simple):** Just auto-map based on Column Name == Field Name.
* "Generate Forms" button.
4. **Logic:**
* Read Excel rows.
* For each row, create a dictionary `{'FieldName': 'Value'}`.
* Clone PDF writer.
* `writer.update_page_form_field_values(writer.pages[0], dictionary)`.
* Save as `Form_[UniqueValue].pdf`.
5. **Deliverables:**
* `form_fill.py`
* `run.bat`
* `requirements.txt`
**Context:** HR generating contracts, Event organizers generating tickets.
🧠 Giải mã Prompt
- Fillable Form: Điều kiện tiên quyết là file PDF phải có các ô nhập liệu (Form Fields). Nếu là PDF thường (Flat PDF), bạn cần dùng Photoshop/Word để tạo form trước, hoặc dùng library vẽ chữ lên tọa độ (như bài Invitation Maker).
🛠️ Hướng dẫn
- Chuẩn bị file PDF Form chuẩn.
- Chuẩn bị Excel có tên cột trùng tên Field.
- Copy Prompt -> Paste -> Chạy.