1
1
from fpdf import FPDF
2
2
from prettytable import PrettyTable
3
3
4
- article = PrettyTable ([ "Pros" , "Cons" ])
4
+ # pdf = FPDF class
5
5
pdf = FPDF ()
6
+ # pdf page set to portrait, A4 size
6
7
pdf = FPDF (orientation = "p" , format = "A4" )
7
8
8
9
# adds page to document
9
10
pdf .add_page ()
10
11
11
- """
12
- # adding images to document (with hyperlink)
13
- pdf.image("", x=175, y=5, w=30, h=30, link="")
14
- pdf.image("", x=175, y=37, w=30, h=30, link="")
15
-
16
- """
17
-
12
+ # title
18
13
pdf .set_font ("Arial" , size = 17 )
19
- pdf .cell (w = 0 , h = 5 , txt = "Why should you learn Python in 2022?" , ln = 1 )
14
+ pdf .cell (w = 0 , h = 7 , txt = "Why should you learn Python in 2022?" , ln = 1 )
20
15
16
+ # article by
21
17
pdf .set_font ("Arial" , size = 10 )
22
- pdf .cell (w = 0 , h = 10 , txt = "By Arsalan Arref" , ln = 1 )
18
+ pdf .cell (w = 0 , h = 5 , txt = "By Arsalan Arref" , ln = 1 )
19
+
20
+ pdf .set_font ("Arial" , size = 8 )
21
+ pdf .set_text_color (194 ,8 ,6 )
22
+ pdf .cell (w = 0 , h = 10 , txt = "This PDF has been coded with Python (FPDF library)" )
23
23
24
24
# set position
25
25
pdf .set_xy (x = 10 , y = 30 )
26
26
pdf .set_font ("Arial" , style = "B" , size = 10 )
27
+ pdf .set_text_color (0 ,0 ,0 )
27
28
pdf .cell (w = 0 , h = 5 , txt = "Temp" , ln = 1 )
28
29
29
30
pdf .set_font ("Arial" , size = 10 )
62
63
"* Diabetes prediction\n " +
63
64
"* Breast cancer detection" )
64
65
65
-
66
+ # 2. data visualization
66
67
pdf .set_xy (x = 10 , y = 150 )
67
68
pdf .set_font ("Arial" , style = "B" , size = 10 )
68
69
pdf .cell (w = 0 , h = 5 , txt = " 2. Data Visualization" , ln = 1 )
75
76
"Examples of data visualization:\n " +
76
77
"https://www.tableau.com/learn/articles/best-beautiful-data-visualization-examples" )
77
78
79
+ # data visualization image
78
80
pdf .image ("data-visualization.png" , x = 10 , y = 180 , w = 90 , h = 50 )
79
81
80
- pdf .set_xy (x = 10 , y = 235 )
82
+ # 3. game development
83
+ pdf .set_xy (x = 105 , y = 190 )
84
+ pdf .set_font ("Arial" , style = "B" , size = 10 )
85
+ pdf .cell (w = 0 , h = 5 , txt = " 3. Game Development" , ln = 1 )
86
+
87
+ pdf .set_xy (x = 105 , y = 200 )
88
+ pdf .set_font ("Arial" , size = 10 )
89
+ pdf .multi_cell (w = 95 , h = 5 , txt = "You can use PyGame library to create your very own 2D games, for example, " +
90
+ "Flappy Bird, Snake, Chess, World of Tanks and so much more!." +
91
+ "You can find games created and published by the community in the link below: " +
92
+ "https://www.pygame.org/news" )
93
+
94
+
95
+ pdf .set_xy (x = 10 , y = 240 )
81
96
pdf .set_font ("Arial" , style = "B" , size = 10 )
82
- pdf .cell (w = 0 , h = 5 , txt = " 3. Game Development" )
97
+ pdf .cell (w = 0 , h = 5 , txt = " Conclusion" , ln = 1 )
83
98
84
99
pdf .set_font ("Arial" , size = 10 )
85
- pdf .multi_cell (w = 0 , h = 5 , txt = "You can use PyGame library to create your very own 2D games, for example, " +
86
- "Flappy Bird, Snake, Chess, World of Tanks and so much more!." )
100
+ pdf .multi_cell (w = 120 , h = 5 , txt = "There are many applications that you can create with Python, from scraping " +
101
+ "live data, to creating automation's, so much more." +
102
+ "Take a look at my GitHub repositories for some ideas on what " +
103
+ "you can create: https://github.com/Azzy001" )
87
104
105
+ pdf .image ("pygame.jpg" , x = 140 , y = 240 , w = 60 , h = 50 )
88
106
89
107
# name document and add its path
90
108
pdf .output ("project.pdf" )
0 commit comments