This Python program is an implementation to CS50’s Introduction to Programming with Python Week 8 - CS50 Shirtificate Problem Set. The CS50 Shirtificate program, implemented in shirtificate.py
, creates a customized PDF certificate with a user's name overlaid on an image of a CS50 "I took CS50" t-shirt.
The Shirtificate
class is a subclass of the FPDF
class from the fpdf2
library. It is designed to create a PDF certificate with the following features:
- The PDF is in portrait orientation.
- The format of the PDF is A4 (210mm wide by 297mm tall).
- The top of the PDF says "CS50 Shirtificate" as text, centered horizontally.
- The shirt's image is centered horizontally.
- The user's name is on top of the shirt in white text.
-
Open your terminal.
-
Navigate to the directory where you have saved the
shirtificate.py
file.cd path/to/your/directory
-
Run the program using the
python
command:python shirtificate.py
-
The program will interactively prompt you to enter your name.
-
After entering your name, a file named
shirtificate.pdf
will be generated in the same directory.
The Shirtificate
class is designed to create a shirtificate with the user's name on it. Here's how it works:
- The
header
method adds the "CS50 Shirtificate" header to the top of the PDF. - The
create_shirtificate
method adds the shirt's image, the user's name, and other details to the PDF. - The
main
function collects the user's name, creates an instance of theShirtificate
class, and generates the shirtificate PDF.
-
Open your terminal.
-
Navigate to the directory where you have saved the
shirtificate.py
file.cd path/to/your/directory
-
Run the tests using the
check50
command:check50 cs50/problems/2022/python/shirtificate
-
The tests will run, and you will see the results indicating whether the program passes each test case.
To submit your work, use the following command in your terminal:
submit50 cs50/problems/2022/python/shirtificate
This will allow CS50 to test your program and provide feedback on its correctness.
- The program uses the
fpdf2
library to create the PDF certificate. - The
Shirtificate
class extends the functionality of theFPDF
class to customize the shirtificate's appearance. - The program prompts the user for their name and generates a customized PDF certificate.
- The generated PDF certificate,
shirtificate.pdf
, will be created in the same directory as theshirtificate.py
file.