0
I am developing an automatic certificate issuance project where I use the pandas
to pull the names of a spreadsheet and Pillow to write the names in the certificate.
The problem occurs when printing the names in the image. I used the for
to go through the array of names and write each one in an image, but what happens is that all the names are written in one image only, with only the first name of the list in a separate image.
I’ve tried using the while
and the def
but only got more bugs. My code below:
from PIL import Image, ImageDraw, ImageFont
import pandas as pd
pessoas = pd.read_excel(r"pessoas.xlsx")
nome = (pessoas['NOME'])
# Definir o modelo do certificado e as fontes que serão utilizadas
im = Image.open('certificado.png')
fnt = ImageFont.truetype("font/Twenty One.ttf", 50)
fnt2 = ImageFont.truetype("font/Cinzel-Regular.otf", 20)
texto = ImageDraw.Draw(im)
date = ['10/10/1000',(155, 300)] # cordenadas da data da emissão
inst = ['Instituição', (485, 300)] # cordenadas do nome da INSTITUIÇÃO
# Cordenadas - NOME // DATA // INSTITUIÇÃO
cord = [(230, 210),(155, 300),(485, 300)]
for x in nome:
texto.text(cord[0], x, font=fnt, fill=('black'))
texto.text(cord[1], date[0], font=fnt2, fill=('black'))
texto.text(cord[2], inst[0], font=fnt2, fill=('black'))
im.show()
impressed how simple it was to solve haha thank you very much had not me attack to that had already tried to create a function with these parameters and gave the same problem but following your tip worked very well
– Alan Jesus