certificate-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCertificate Generator
证书生成器
Create professional certificates for courses, achievements, events, and awards. Supports batch generation from CSV files with customizable templates and branding.
为课程、成果、活动和奖项创建专业证书。支持通过CSV文件批量生成,可自定义模板和品牌标识。
Quick Start
快速开始
python
from scripts.certificate_gen import CertificateGeneratorpython
from scripts.certificate_gen import CertificateGeneratorSingle certificate
单个证书
cert = CertificateGenerator()
cert.set_title("Certificate of Completion")
cert.set_recipient("John Smith")
cert.set_achievement("Python Programming Course")
cert.set_date("December 14, 2024")
cert.generate().save("certificate.pdf")
cert = CertificateGenerator()
cert.set_title("Certificate of Completion")
cert.set_recipient("John Smith")
cert.set_achievement("Python Programming Course")
cert.set_date("December 14, 2024")
cert.generate().save("certificate.pdf")
Batch from CSV
从CSV批量生成
CertificateGenerator.batch_generate(
"students.csv",
template="achievement",
title="Certificate of Completion",
achievement="Data Science Bootcamp",
output_dir="./certificates/"
)
undefinedCertificateGenerator.batch_generate(
"students.csv",
template="achievement",
title="Certificate of Completion",
achievement="Data Science Bootcamp",
output_dir="./certificates/"
)
undefinedFeatures
功能特性
- Professional Templates: Modern, classic, elegant, minimal styles
- Custom Branding: Logo, colors, signatures
- Batch Generation: Create hundreds of certificates from CSV
- Dynamic Fields: Name, date, achievement, instructor, etc.
- Signatures: Text or image signatures with titles
- Certificate IDs: Auto-generated unique identifiers
- Export: PDF output, landscape or portrait
- 专业模板:现代、经典、优雅、极简等多种风格
- 自定义品牌:支持添加Logo、自定义配色、签名
- 批量生成:通过CSV文件批量创建数百份证书
- 动态字段:姓名、日期、成果、讲师等字段可自定义
- 签名功能:支持文本或图片签名,并可添加职位
- 证书ID:自动生成唯一标识符
- 导出功能:导出为PDF,支持横向或纵向布局
API Reference
API 参考
Initialization
初始化
python
cert = CertificateGenerator()python
cert = CertificateGenerator()With template
使用指定模板
cert = CertificateGenerator(template="elegant")
undefinedcert = CertificateGenerator(template="elegant")
undefinedCertificate Content
证书内容设置
python
undefinedpython
undefinedTitle
设置标题
cert.set_title("Certificate of Completion")
cert.set_title("Certificate of Achievement")
cert.set_title("Certificate of Completion")
cert.set_title("Certificate of Achievement")
Recipient name
设置收件人姓名
cert.set_recipient("Jane Doe")
cert.set_recipient("Jane Doe")
Achievement/course/event
设置成果/课程/活动
cert.set_achievement("Advanced Python Programming")
cert.set_achievement("for outstanding performance in the 2024 Hackathon")
cert.set_achievement("Advanced Python Programming")
cert.set_achievement("for outstanding performance in the 2024 Hackathon")
Description (optional)
设置描述(可选)
cert.set_description(
"Has successfully completed the 40-hour intensive course "
"covering advanced topics in Python programming."
)
cert.set_description(
"Has successfully completed the 40-hour intensive course "
"covering advanced topics in Python programming."
)
Date
设置日期
cert.set_date("December 14, 2024")
cert.set_date_auto() # Use today's date
cert.set_date("December 14, 2024")
cert.set_date_auto() # 使用当前日期
Certificate ID (auto-generated if not set)
设置证书ID(未设置则自动生成)
cert.set_certificate_id("CERT-2024-001")
undefinedcert.set_certificate_id("CERT-2024-001")
undefinedBranding
品牌标识设置
python
undefinedpython
undefinedOrganization name
设置机构名称
cert.set_organization("Acme Academy")
cert.set_organization("Acme Academy")
Logo
设置Logo
cert.set_logo("logo.png")
cert.set_logo("logo.png", width=200)
cert.set_logo("logo.png")
cert.set_logo("logo.png", width=200)
Colors
设置配色
cert.set_colors(
primary="#1e3a5f", # Main color (title, borders)
accent="#c9a227", # Accent color (decorations)
text="#333333" # Text color
)
undefinedcert.set_colors(
primary="#1e3a5f", # 主色调(标题、边框)
accent="#c9a227", # 强调色(装饰元素)
text="#333333" # 文字颜色
)
undefinedSignatures
签名设置
python
undefinedpython
undefinedText signature
文本签名
cert.add_signature(
name="Dr. Jane Smith",
title="Program Director"
)
cert.add_signature(
name="Dr. Jane Smith",
title="Program Director"
)
Multiple signatures
添加多个签名
cert.add_signature("John Doe", "CEO")
cert.add_signature("Jane Smith", "Head of Training")
cert.add_signature("John Doe", "CEO")
cert.add_signature("Jane Smith", "Head of Training")
Image signature
图片签名
cert.add_signature(
name="Dr. Jane Smith",
title="Program Director",
signature_image="signature.png"
)
undefinedcert.add_signature(
name="Dr. Jane Smith",
title="Program Director",
signature_image="signature.png"
)
undefinedTemplates
模板设置
python
undefinedpython
undefinedAvailable templates
可用模板
cert.set_template("modern") # Clean, contemporary design
cert.set_template("classic") # Traditional, formal design
cert.set_template("elegant") # Decorative borders, serif fonts
cert.set_template("minimal") # Simple, clean design
cert.set_template("academic") # University/school style
cert.set_template("modern") # 简洁现代设计
cert.set_template("classic") # 传统正式设计
cert.set_template("elegant") # 装饰性边框,衬线字体
cert.set_template("minimal") # 极简干净设计
cert.set_template("academic") # 院校风格
Orientation
设置页面方向
cert.set_orientation("landscape") # Default
cert.set_orientation("portrait")
undefinedcert.set_orientation("landscape") # 默认横向
cert.set_orientation("portrait") # 纵向
undefinedGeneration and Export
生成与导出
python
undefinedpython
undefinedGenerate certificate
生成证书
cert.generate()
cert.generate()
Save to PDF
保存为PDF
cert.save("certificate.pdf")
cert.save("certificate.pdf")
Get PDF bytes
获取PDF字节流
pdf_bytes = cert.to_bytes()
undefinedpdf_bytes = cert.to_bytes()
undefinedBatch Generation
批量生成
From CSV
从CSV生成
python
undefinedpython
undefinedCSV with recipient data
包含收件人数据的CSV
CertificateGenerator.batch_generate(
csv_file="students.csv",
template="achievement",
title="Certificate of Completion",
achievement="Python Fundamentals",
organization="Code Academy",
output_dir="./certificates/"
)
undefinedCertificateGenerator.batch_generate(
csv_file="students.csv",
template="achievement",
title="Certificate of Completion",
achievement="Python Fundamentals",
organization="Code Academy",
output_dir="./certificates/"
)
undefinedCSV Format
CSV格式
csv
name,date,course,certificate_id
John Smith,2024-12-14,Python 101,CERT-001
Jane Doe,2024-12-14,Python 101,CERT-002
Bob Johnson,2024-12-14,Python 101,CERT-003csv
name,date,course,certificate_id
John Smith,2024-12-14,Python 101,CERT-001
Jane Doe,2024-12-14,Python 101,CERT-002
Bob Johnson,2024-12-14,Python 101,CERT-003Programmatic Batch
程序化批量生成
python
recipients = [
{"name": "John Smith", "course": "Python 101"},
{"name": "Jane Doe", "course": "Data Science"},
{"name": "Bob Johnson", "course": "Machine Learning"}
]
for r in recipients:
cert = CertificateGenerator(template="modern")
cert.set_title("Certificate of Completion")
cert.set_recipient(r["name"])
cert.set_achievement(r["course"])
cert.set_date_auto()
cert.generate()
cert.save(f"certificates/{r['name'].replace(' ', '_')}.pdf")python
recipients = [
{"name": "John Smith", "course": "Python 101"},
{"name": "Jane Doe", "course": "Data Science"},
{"name": "Bob Johnson", "course": "Machine Learning"}
]
for r in recipients:
cert = CertificateGenerator(template="modern")
cert.set_title("Certificate of Completion")
cert.set_recipient(r["name"])
cert.set_achievement(r["course"])
cert.set_date_auto()
cert.generate()
cert.save(f"certificates/{r['name'].replace(' ', '_')}.pdf")CLI Usage
CLI 用法
bash
undefinedbash
undefinedSingle certificate
生成单个证书
python certificate_gen.py
--recipient "John Smith"
--title "Certificate of Completion"
--achievement "Python Course"
--output certificate.pdf
--recipient "John Smith"
--title "Certificate of Completion"
--achievement "Python Course"
--output certificate.pdf
python certificate_gen.py
--recipient "John Smith"
--title "Certificate of Completion"
--achievement "Python Course"
--output certificate.pdf
--recipient "John Smith"
--title "Certificate of Completion"
--achievement "Python Course"
--output certificate.pdf
With options
带参数生成
python certificate_gen.py
--recipient "Jane Doe"
--title "Certificate of Achievement"
--achievement "Excellence in Data Science"
--organization "Data Academy"
--template elegant
--logo logo.png
--output achievement.pdf
--recipient "Jane Doe"
--title "Certificate of Achievement"
--achievement "Excellence in Data Science"
--organization "Data Academy"
--template elegant
--logo logo.png
--output achievement.pdf
python certificate_gen.py
--recipient "Jane Doe"
--title "Certificate of Achievement"
--achievement "Excellence in Data Science"
--organization "Data Academy"
--template elegant
--logo logo.png
--output achievement.pdf
--recipient "Jane Doe"
--title "Certificate of Achievement"
--achievement "Excellence in Data Science"
--organization "Data Academy"
--template elegant
--logo logo.png
--output achievement.pdf
Batch from CSV
从CSV批量生成
python certificate_gen.py
--batch students.csv
--title "Certificate of Completion"
--achievement "Bootcamp Graduate"
--template modern
--output-dir ./certificates/
--batch students.csv
--title "Certificate of Completion"
--achievement "Bootcamp Graduate"
--template modern
--output-dir ./certificates/
undefinedpython certificate_gen.py
--batch students.csv
--title "Certificate of Completion"
--achievement "Bootcamp Graduate"
--template modern
--output-dir ./certificates/
--batch students.csv
--title "Certificate of Completion"
--achievement "Bootcamp Graduate"
--template modern
--output-dir ./certificates/
undefinedCLI Arguments
CLI 参数
| Argument | Description | Default |
|---|---|---|
| Recipient name | Required |
| Certificate title | |
| Achievement text | - |
| Description text | - |
| Organization name | - |
| Certificate date | Today |
| Template style | |
| Logo image path | - |
| Output PDF path | |
| CSV file for batch | - |
| Output directory (batch) | |
| 参数 | 描述 | 默认值 |
|---|---|---|
| 收件人姓名 | 必填 |
| 证书标题 | |
| 成果描述文本 | - |
| 详细描述文本 | - |
| 机构名称 | - |
| 证书日期 | 今日 |
| 模板风格 | |
| Logo图片路径 | - |
| 输出PDF路径 | |
| 批量生成用的CSV文件 | - |
| 批量生成的输出目录 | |
Templates
模板介绍
Modern
Modern(现代风格)
Clean, contemporary design with:
- Sans-serif fonts
- Minimal decorations
- Bold color accents
- Professional look
简洁现代的设计,特点:
- 无衬线字体
- 极简装饰
- 醒目色彩强调
- 专业外观
Classic
Classic(经典风格)
Traditional design with:
- Serif fonts
- Formal layout
- Border decorations
- Timeless elegance
传统正式的设计,特点:
- 衬线字体
- 正式布局
- 边框装饰
- 永恒优雅
Elegant
Elegant(优雅风格)
Decorative design with:
- Ornate borders
- Script fonts for name
- Gold accents
- Premium feel
装饰性设计,特点:
- 华丽边框
- 姓名使用手写风格字体
- 金色强调
- 高端质感
Minimal
Minimal(极简风格)
Simple design with:
- Clean typography
- No decorations
- Lots of white space
- Modern simplicity
简洁干净的设计,特点:
- 清晰排版
- 无装饰元素
- 大量留白
- 现代简约
Academic
Academic(院校风格)
University style with:
- Seal/crest placement
- Formal typography
- Official appearance
- Traditional layout
大学/学校风格,特点:
- 校徽/纹章布局
- 正式排版
- 官方外观
- 传统布局
Examples
使用示例
Course Completion Certificate
课程结业证书
python
cert = CertificateGenerator(template="modern")
cert.set_title("Certificate of Completion")
cert.set_recipient("John Smith")
cert.set_achievement("Full Stack Web Development")
cert.set_description(
"Has successfully completed the 12-week intensive program "
"covering HTML, CSS, JavaScript, React, Node.js, and databases."
)
cert.set_organization("Tech Academy")
cert.set_logo("tech_academy_logo.png")
cert.set_date("December 14, 2024")
cert.add_signature("Sarah Johnson", "Program Director")
cert.generate().save("completion_cert.pdf")python
cert = CertificateGenerator(template="modern")
cert.set_title("Certificate of Completion")
cert.set_recipient("John Smith")
cert.set_achievement("Full Stack Web Development")
cert.set_description(
"Has successfully completed the 12-week intensive program "
"covering HTML, CSS, JavaScript, React, Node.js, and databases."
)
cert.set_organization("Tech Academy")
cert.set_logo("tech_academy_logo.png")
cert.set_date("December 14, 2024")
cert.add_signature("Sarah Johnson", "Program Director")
cert.generate().save("completion_cert.pdf")Achievement Award
成就奖项证书
python
cert = CertificateGenerator(template="elegant")
cert.set_title("Certificate of Achievement")
cert.set_recipient("Jane Doe")
cert.set_achievement("First Place - Annual Hackathon 2024")
cert.set_organization("Innovation Labs")
cert.set_colors(primary="#1a1a2e", accent="#d4af37")
cert.add_signature("Michael Chen", "CEO")
cert.add_signature("Emily Brown", "CTO")
cert.generate().save("achievement_award.pdf")python
cert = CertificateGenerator(template="elegant")
cert.set_title("Certificate of Achievement")
cert.set_recipient("Jane Doe")
cert.set_achievement("First Place - Annual Hackathon 2024")
cert.set_organization("Innovation Labs")
cert.set_colors(primary="#1a1a2e", accent="#d4af37")
cert.add_signature("Michael Chen", "CEO")
cert.add_signature("Emily Brown", "CTO")
cert.generate().save("achievement_award.pdf")Workshop Participation
Workshop参与证书
python
cert = CertificateGenerator(template="minimal")
cert.set_title("Certificate of Participation")
cert.set_recipient("Bob Wilson")
cert.set_achievement("Machine Learning Workshop")
cert.set_description("Attended the 2-day intensive workshop on Dec 12-13, 2024")
cert.set_date_auto()
cert.generate().save("workshop_cert.pdf")python
cert = CertificateGenerator(template="minimal")
cert.set_title("Certificate of Participation")
cert.set_recipient("Bob Wilson")
cert.set_achievement("Machine Learning Workshop")
cert.set_description("Attended the 2-day intensive workshop on Dec 12-13, 2024")
cert.set_date_auto()
cert.generate().save("workshop_cert.pdf")Batch Employee Training
批量员工培训证书
python
undefinedpython
undefinedtraining_completed.csv
training_completed.csv
name,department,course
name,department,course
Alice,Engineering,Safety Training
Alice,Engineering,Safety Training
Bob,Sales,Product Training
Bob,Sales,Product Training
Carol,HR,Compliance Training
Carol,HR,Compliance Training
CertificateGenerator.batch_generate(
csv_file="training_completed.csv",
template="classic",
title="Training Completion Certificate",
organization="Acme Corp",
logo="acme_logo.png",
output_dir="./training_certs/",
filename_pattern="{name}_{course}.pdf"
)
undefinedCertificateGenerator.batch_generate(
csv_file="training_completed.csv",
template="classic",
title="Training Completion Certificate",
organization="Acme Corp",
logo="acme_logo.png",
output_dir="./training_certs/",
filename_pattern="{name}_{course}.pdf"
)
undefinedDependencies
依赖项
reportlab>=4.0.0
Pillow>=10.0.0reportlab>=4.0.0
Pillow>=10.0.0Limitations
限制说明
- PDF output only (no PNG/image export)
- Pre-defined templates (no custom HTML/CSS)
- Maximum 3 signatures per certificate
- Logo should be PNG or JPEG
- English templates only (RTL languages not supported)
- 仅支持PDF输出(不支持PNG/图片导出)
- 仅提供预定义模板(不支持自定义HTML/CSS)
- 每份证书最多添加3个签名
- Logo需为PNG或JPEG格式
- 仅支持英文模板(不支持RTL语言)