0% found this document useful (0 votes)
2 views1 page

code2pdf_6844251e225f9

The document is a Python script that generates a PDF template for an Employee Master Data and Salary Sheet using the FPDF library. It includes sections for employee details such as ID, name, designation, and salary information, formatted in tables. The script initializes a PDF, adds a header, and populates it with sample employee and salary data.

Uploaded by

kaushik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

code2pdf_6844251e225f9

The document is a Python script that generates a PDF template for an Employee Master Data and Salary Sheet using the FPDF library. It includes sections for employee details such as ID, name, designation, and salary information, formatted in tables. The script initializes a PDF, adds a header, and populates it with sample employee and salary data.

Uploaded by

kaushik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

class PDF(FPDF):

def header(self):
self.set_font("Arial", "B", 12)
self.cell(0, 10, "Employee Master Data and Salary Sheet Template", ln=True, align="C")
self.ln(5)

def chapter_title(self, title):


self.set_font("Arial", "B", 12)
self.cell(0, 10, title, ln=True)
self.ln(2)

def table(self, col_widths, data, align='L'):


self.set_font("Arial", size=10)
for row in data:
for i in range(len(row)):
self.cell(col_widths[i], 8, str(row[i]), border=1, align=align)
self.ln()

# Initialize PDF
pdf = PDF()
pdf.add_page()

# Employee Master Data


pdf.chapter_title("Employee Master Data Sheet")

emp_headers = [
"Employee ID", "Name", "Designation", "Department", "Date of Joining",
"PAN No.", "Bank A/C No.", "IFSC Code", "Email", "Phone", "Salary Grade"
]
emp_data = [
["EMP001", "John Doe", "Software Engineer", "IT", "2021-03-01", "ABCPD1234K",
"123456789012", "HDFC0001234", "[email protected]", "9876543210", "Grade A"],
["EMP002", "Jane Smith", "HR Manager", "HR", "2020-07-15", "XYZPD5678L",
"987654321098", "ICIC0005678", "[email protected]", "8765432109", "Grade B"]
]

pdf.table([20, 25, 35, 25, 25, 25, 30, 25, 45, 25, 25], [emp_headers] + emp_data)

# Salary Sheet
pdf.ln(10)
pdf.chapter_title("Salary Sheet Template")

salary_headers = [
"Month", "Employee ID", "Name", "Basic Pay", "HRA", "Conveyance", "Other Allowances",
"Gross Salary", "PF Deduction", "ESI", "Income Tax", "Other Deductions", "Net Salary"
]
salary_data = [
["June 2025", "EMP001", "John Doe", "30,000", "12,000", "2,000", "3,000", "47,000",
"3,600", "0", "2,000", "500", "40,900"],
["June 2025", "EMP002", "Jane Smith", "40,000", "16,000", "2,000", "2,000", "60,000",
"4,800", "0", "3,500", "700", "51,000"]
]

pdf.table([20, 20, 25, 20, 15, 20, 25, 25, 20, 10, 20, 25, 20], [salary_headers] + salary_data)

You might also like