Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

python 3.x - How do I generate Batches of PDF for Course Completion Certificate?

I work for a company where we need to generate PDF certificates for our students. Currently, this task is being handled by manually editing and exporting the PDF files.

What I have built now works in a manner where my code fetches a Template Image and writes names and company name from an excel sheet.

The Issue: The text placed is not properly aligned due to string length.

import pandas as pd
from PIL import Image, ImageDraw, ImageFont

data = pd.read_excel(r'D:CDACCertificate GeneratorNames.xlsx')


name_list = data["Name"].tolist() 
company_list = data["Company"].tolist()
store = len(name_list)
for i in range(0,store):
 im = Image.open(r'D:CDACCertificate Generatorcdac certificate.jpg')
 d = ImageDraw.Draw(im)
 location = (350, 370)
 text_color = (0, 0, 0)
 font = ImageFont.truetype("times.ttf", 40)
 d.text(location, name_list[i], fill = text_color, font = font)
 location = (287, 411)
 text_color = (0, 0, 0)
 font = ImageFont.truetype("times.ttf", 40)
 d.text(location, company_list[i], fill = text_color, font = font)
 im.save("certificate_" + name_list[i] + ".pdf")

template image enter image description here

question from:https://stackoverflow.com/questions/66058426/how-do-i-generate-batches-of-pdf-for-course-completion-certificate

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...