How to generate Certificates Use Python
--Github
--
Code
# Import libraries
import pandas as pd
from PIL import Image, ImageDraw, ImageFont
# Read an excel named file_name.xlsx
data = pd.read_excel('file_name.xlsx')
# create list of names from Column "Name" in that excel sheet
name_list = data["Name"].tolist()
print(name_list)
for i in name_list:
# read certificate model
im = Image.open("cert_model.png")
background = Image.new("RGB", im.size, (255, 255, 255))
background.paste(im, mask=im.split()[3]) # 3 is the alpha channel
im=background
d = ImageDraw.Draw(im)
# Set location to draw names
location = (100, 398)
text_color = (0, 137, 209)
# define font and size
font = ImageFont.truetype("Fonts/Oswald-Bold.ttf", 120)
d.text(location, i, fill = text_color, font = font)
# to save
im.save("Generate/CID_" + i + ".pdf")