File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments