Problem: Generating certificates manually for each student who completes a course can be cumbersome.
Solution: Automatically generates certificates for students upon course completion.
Benefits: Saves time, reduces the workload on instructors, and automates the certification process.
Adoption: This can be customized with specific designs, logos, and personalized messages for each certificate.
Code:
from fpdf import FPDF
# Function to generate certificate
def generate_certificate(student_name, course_name):
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
# Title
pdf.cell(200, 10, txt=f"Certificate of Completion", ln=True, align='C')
pdf.ln(20)
# Body
pdf.set_font('Arial', '', 12)
pdf.cell(200, 10, txt=f"This is to certify that {student_name} has completed the course", ln=True, align='C')
pdf.cell(200, 10, txt=f"'{course_name}' with excellence.", ln=True, align='C')
# Output PDF
pdf.output(f"{student_name}_certificate.pdf")
print(f"Certificate generated for {student_name}.")
# Generate certificate
generate_certificate("John Doe", "Python Programming")
No comments:
Post a Comment