23 lines
756 B
Python
23 lines
756 B
Python
from fpdf import FPDF
|
|
|
|
|
|
def main():
|
|
username = input("What's your name?\t\t")
|
|
pdf = FPDF(orientation="P", unit="mm", format="A4")
|
|
pdf.set_auto_page_break(False)
|
|
pdf.add_page()
|
|
pdf.set_font("helvetica", "B", 45)
|
|
pdf.cell(0, 10, 'CS50 Shirtificate', new_x="LMARGIN", new_y="NEXT", align='C')
|
|
page_width = pdf.w
|
|
total_horizontal_margin = 0.2 * page_width
|
|
image_width = pdf.w-total_horizontal_margin
|
|
pdf.image("shirtificate.png", x=total_horizontal_margin/2, y=50, w=image_width)
|
|
pdf.set_font("helvetica", "B", 32)
|
|
pdf.set_text_color(255, 255, 255)
|
|
pdf.cell(0, 230, f'{username} took CS50', new_x="LMARGIN", new_y="NEXT", align='C')
|
|
pdf.output("shirtificate.pdf")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|