Queer European MD passionate about IT

shirtificate.py 756 B

12345678910111213141516171819202122
  1. from fpdf import FPDF
  2. def main():
  3. username = input("What's your name?\t\t")
  4. pdf = FPDF(orientation="P", unit="mm", format="A4")
  5. pdf.set_auto_page_break(False)
  6. pdf.add_page()
  7. pdf.set_font("helvetica", "B", 45)
  8. pdf.cell(0, 10, 'CS50 Shirtificate', new_x="LMARGIN", new_y="NEXT", align='C')
  9. page_width = pdf.w
  10. total_horizontal_margin = 0.2 * page_width
  11. image_width = pdf.w-total_horizontal_margin
  12. pdf.image("shirtificate.png", x=total_horizontal_margin/2, y=50, w=image_width)
  13. pdf.set_font("helvetica", "B", 32)
  14. pdf.set_text_color(255, 255, 255)
  15. pdf.cell(0, 230, f'{username} took CS50', new_x="LMARGIN", new_y="NEXT", align='C')
  16. pdf.output("shirtificate.pdf")
  17. if __name__ == '__main__':
  18. main()