Skip to content

Commit 0b93a97

Browse files
committed
Create shirtificate.py
1 parent 1348358 commit 0b93a97

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from fpdf import FPDF
2+
3+
class ShirtificatePDF(FPDF):
4+
"""
5+
Cs50 ShirtificatePDF class
6+
"""
7+
def __init__(self):
8+
super().__init__()
9+
self.image("./shirtificate.png", w=self.epw) # 15, 80, 180
10+
self.set_font("helvetica", "B", size=52)
11+
self.cell(0, 58, "CS50 Shirtificate", align="C")
12+
self.ln(20)
13+
14+
def get_name_on_shirt(self, name:str):
15+
name = input("Name: ")
16+
self.name = name
17+
18+
def make_shirt(self):
19+
self.add_page(orientation="portrait", format="A4")
20+
text = f"{self.name} took CS50"
21+
self.set_text_color(r=255,g=255,b=255)
22+
self.set_font("helvetica", size=24)
23+
self.cell(0, 213, text, align="C")
24+
self.output("shirtificate.pdf")
25+
26+
def main():
27+
pdf = ShirtificatePDF()
28+
pdf.get_name_on_shirt()
29+
pdf.make_shirt()
30+
31+
if __name__ == "__main__":
32+
main()

0 commit comments

Comments
 (0)