Automatic Certificate Generator in Python

ASWINI SUGUNA
2 min readJul 4, 2021

Hurray Developers,

Today I am going to discuss one situation with you, considering you are an organizer of an event with more than 500 candidates and as usual if you are the organizer of the event means, we have one burden: manual work(i.e) Sending participation certificates to all attendees.

Now the entire world is booming around the word called automation. Yeah, We use automation features to automate this manual thing ! Just 30 lines will save your precious time.

Prerequisite :

  • python3
  • PI,pillow,pandas.

To install the above packages :

  • pip install PI
  • pip install pandas
  • pip install pillow

After completion of installation of all packages, the next step is to prepare a CSV file.

Now the input CSV file is ready to process, the immediate step is to point the coordinate in the template certificate where you want to write.

To find the coordinate point, we can use a specific package called pyautogui

import pyautogui as pg

pg.position() // To find the coordinates.

Algorithm :

> Import all the required packages such as imghdr,ImageDraw, ImageFont,import Image pandas os smtplib, csv,EmailMessage.

> To give necessary font type and size of font. Check with locate .ttf — Used to locate the default font types.

> To get the connection, we need to configure smtp ssl with your credentials.

> Iterate through the input csv file and write whatever text on the template by using coordinate points of the certificate. After writing, save the certificate with the candidate name itself.

> To send the certificate to their respective participants, Extract the receiver mail id from the csv file and add it in the body content using EmailMessage function().

> Now the saved image is open and read in binary format then add the image to the message content of the email. Finally by passing this message into the sendmessage function in smtp package, our certificate is dispatched and ready to receive in the participants inbox.

Note : It will take some time to generate based on the number of candidates.

Source Code :

Congratulations, We did it, We solved one of the burden manual work !!

--

--