save pdf
Browse files
app.py
CHANGED
@@ -344,15 +344,20 @@ def generate_certificate(certificate_model, first_name, last_name):
|
|
344 |
# Date of certification
|
345 |
d.text((1480, 1170), str(date.today()), fill="black", anchor="mm", font=date_font)
|
346 |
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
pdf =
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
return im, pdf
|
358 |
|
|
|
344 |
# Date of certification
|
345 |
d.text((1480, 1170), str(date.today()), fill="black", anchor="mm", font=date_font)
|
346 |
|
347 |
+
|
348 |
+
pdf = im.convert('RGB')
|
349 |
+
pdf.save('certificate.pdf')
|
350 |
+
print("PDF: ", pdf)
|
351 |
+
|
352 |
+
# rgba = im
|
353 |
+
# rgb = Image.new('RGB', im.size, (255, 255, 255)) # white background
|
354 |
+
# rgb.paste(rgba, mask=rgba.split()[3]) # 3 is the alpha channel
|
355 |
+
# pdf_ = rgb.save("certificate.pdf", 'PDF', save_all = True, resolution=100.0)
|
356 |
+
# pdf__ = im.save("certificate.png")
|
357 |
+
# print("RGB", rgb)
|
358 |
+
# print("PDF", pdf_)
|
359 |
+
# print("PDF", pdf__)
|
360 |
+
# pdf = pdf_.filename
|
361 |
|
362 |
return im, pdf
|
363 |
|