Skip to content

Commit c54528d

Browse files
Merge pull request #4 from ganpa27/reporter
Reporter
2 parents 6f300bf + f5c2b8c commit c54528d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

reporter/__init__.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import fpdf
2+
import os
3+
4+
5+
class Basics:
6+
def __init__(self):
7+
self.pdf = fpdf.FPDF(orientation='P', unit='mm', format='A4')
8+
9+
def add_page(self):
10+
self.pdf.add_page()
11+
12+
def heading1(self, heading: str = ""):
13+
self.pdf.set_font("times", style="b", size=16)
14+
self.pdf.cell(40, 10, heading)
15+
16+
self.pdf.ln(10)
17+
18+
def heading2(self, heading: str = ""):
19+
self.pdf.set_font("times", style="b", size=14)
20+
self.pdf.cell(40, 10, heading)
21+
22+
self.pdf.ln(10)
23+
24+
def heading3(self, heading: str = ""):
25+
self.pdf.set_font("times", style="b", size=12)
26+
self.pdf.cell(40, 10, heading)
27+
28+
self.pdf.ln(10)
29+
30+
def body(self, body_text: str = ""):
31+
self.pdf.set_font("times", size=10)
32+
33+
self.pdf.multi_cell(0, 5, body_text, align="J")
34+
self.pdf.ln(10)
35+
36+
def line(self):
37+
self.pdf.line(10, 20, 200, 20)
38+
39+
def save(self, file_name: str = "output.pdf"):
40+
self.pdf.output(file_name)
41+
42+
def italic(self, text):
43+
self.pdf.set_font("times", style="I", size=10)
44+
self.pdf.multi_cell(0, 5, text, align="J")
45+
self.pdf.ln(10)
46+
47+
48+
if __name__ == "__main__":
49+
obj = Basics()
50+
obj.add_page()
51+
52+
obj.heading1("heading _ 1")
53+
obj.line()
54+
# obj.heading1("ganesh")
55+
# obj.heading1("pratik")
56+
obj.heading2("heading _ 2")
57+
obj.heading3("heading _ 3")
58+
obj.italic("Hello this is italic")
59+
obj.body(
60+
"hello this is ganesh shinde you are a very good programmer hello this is ganesh shinde you are a very good programmer hello this is ganesh shinde you are a very good programmer hello this is ganesh shinde you are a very good programmer hello this is ganesh shinde you are a very good programmer hello this is ganesh shinde you are a very good programmer hello this is ganesh shinde you are a very good programmer")
61+
obj.save()
62+
63+
os.system("open output.pdf")
64+

0 commit comments

Comments
 (0)