fork download
  1. from fpdf import FPDF
  2.  
  3. # Create instance of FPDF class
  4. pdf = FPDF()
  5. pdf.add_page()
  6. pdf.set_auto_page_break(auto=True, margin=15)
  7.  
  8. # Title
  9. pdf.set_font("Arial", 'B', 16)
  10. pdf.cell(0, 10, "ACT Exam Overview", ln=True, align='C')
  11. pdf.ln(5)
  12.  
  13. # Section data
  14. sections = [
  15. {"name": "English", "questions": 75, "marks": 1, "negative": "None", "time_min": 45, "content": "Usage/Mechanics (grammar, punctuation)\nRhetorical Skills (strategy, organization, style)"},
  16. {"name": "Math", "questions": 60, "marks": 1, "negative": "None", "time_min": 60, "content": "Pre-Algebra\nElementary Algebra\nIntermediate Algebra\nCoordinate Geometry\nPlane Geometry\nTrigonometry"},
  17. {"name": "Reading", "questions": 40, "marks": 1, "negative": "None", "time_min": 35, "content": "4 passages: Prose Fiction, Social Science, Humanities, Natural Science"},
  18. {"name": "Science", "questions": 40, "marks": 1, "negative": "None", "time_min": 35, "content": "Data Representation\nResearch Summaries\nConflicting Viewpoints"},
  19. {"name": "Writing (Optional)", "questions": 1, "marks": "2–12", "negative": "N/A", "time_min": 40, "content": "Analyze and evaluate multiple perspectives on an issue"}
  20. ]
  21.  
  22. # Add table header
  23. pdf.set_font("Arial", 'B', 12)
  24. pdf.cell(40, 10, "Section", 1)
  25. pdf.cell(30, 10, "Questions", 1)
  26. pdf.cell(30, 10, "Marks", 1)
  27. pdf.cell(40, 10, "Negative Marking", 1)
  28. pdf.cell(30, 10, "Time (min)", 1)
  29. pdf.ln()
  30.  
  31. # Add table content
  32. pdf.set_font("Arial", '', 12)
  33. for sec in sections:
  34. pdf.cell(40, 10, sec["name"], 1)
  35. pdf.cell(30, 10, str(sec["questions"]), 1)
  36. pdf.cell(30, 10, str(sec["marks"]), 1)
  37. pdf.cell(40, 10, sec["negative"], 1)
  38. pdf.cell(30, 10, str(sec["time_min"]), 1)
  39. pdf.ln()
  40. # Add content description
  41. pdf.multi_cell(0, 8, "Content: " + sec["content"])
  42. pdf.ln(2)
  43.  
  44. # Total summary
  45. pdf.set_font("Arial", 'B', 12)
  46. pdf.ln(5)
  47. pdf.multi_cell(0, 8, "Total Questions (excluding essay): 215\nTotal Time (excluding essay): 175 minutes (~2 hours 55 minutes)")
  48.  
  49. # Save PDF
  50. pdf.output("ACT_Exam_Overview.pdf")
  51. print("PDF generated successfully!")
Success #stdin #stdout 0.04s 25312KB
stdin
1
2
10
42
11
from fpdf import FPDF

# Create a new instance of the PDF class
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)

# Company Information
pdf.cell(200, 10, "COMPANY NAME", ln=True, align='C')
pdf.cell(200, 10, "Company Address", ln=True, align='C')
pdf.cell(200, 10, "Phone: XXXXXXXXXX", ln=True, align='C')
pdf.ln(10)

# Employee Information
pdf.cell(100, 10, "Employee Name: Dipendra Dhakal", ln=True)
pdf.cell(100, 10, "Employee ID: 288550617", ln=True)
pdf.cell(100, 10, "Designation: Service Provider", ln=True)
pdf.cell(100, 10, "Month: June 2024", ln=True)
pdf.ln(10)

# Earnings
pdf.cell(100, 10, "Earnings:", ln=True)
pdf.cell(100, 10, "---------------------------", ln=True)
pdf.cell(100, 10, f"Service Provision: 2500.00 €", ln=True)
pdf.ln(5)
pdf.cell(100, 10, f"Gross Pay: 2500.00 €", ln=True)
pdf.ln(10)

# Deductions
pdf.cell(100, 10, "Deductions:", ln=True)
pdf.cell(100, 10, "---------------------------", ln=True)
pdf.cell(100, 10, f"IVA (23%): 575.00 €", ln=True)
pdf.cell(100, 10, f"IRS (11.5%): -287.50 €", ln=True)
pdf.cell(100, 10, f"Platform Usage Fee: -1.85 €", ln=True)
pdf.ln(5)
pdf.cell(100, 10, f"Total Deductions: 285.65 €", ln=True)
pdf.ln(10)

# Net Pay
pdf.cell(100, 10, f"Net Pay: 2214.35 €", ln=True)
pdf.ln(10)

# Footer
pdf.cell(100, 10, "Signature of Employer: ______________", ln=True)
pdf.cell(100, 10, "Date: 06 June 2024", ln=True)

# Save the PDF
pdf_output_path = "/mnt/data/Salary_Slip_Dipendra_Dhakal_2500.pdf"
pdf.output(pdf_output_path)

pdf_output_path
stdout
from fpdf import FPDF

# Create instance of FPDF class
pdf = FPDF()
pdf.add_page()
pdf.set_auto_page_break(auto=True, margin=15)

# Title
pdf.set_font("Arial", 'B', 16)
pdf.cell(0, 10, "ACT Exam Overview", ln=True, align='C')
pdf.ln(5)

# Section data
sections = [
    {"name": "English", "questions": 75, "marks": 1, "negative": "None", "time_min": 45, "content": "Usage/Mechanics (grammar, punctuation)\nRhetorical Skills (strategy, organization, style)"},
    {"name": "Math", "questions": 60, "marks": 1, "negative": "None", "time_min": 60, "content": "Pre-Algebra\nElementary Algebra\nIntermediate Algebra\nCoordinate Geometry\nPlane Geometry\nTrigonometry"},
    {"name": "Reading", "questions": 40, "marks": 1, "negative": "None", "time_min": 35, "content": "4 passages: Prose Fiction, Social Science, Humanities, Natural Science"},
    {"name": "Science", "questions": 40, "marks": 1, "negative": "None", "time_min": 35, "content": "Data Representation\nResearch Summaries\nConflicting Viewpoints"},
    {"name": "Writing (Optional)", "questions": 1, "marks": "2–12", "negative": "N/A", "time_min": 40, "content": "Analyze and evaluate multiple perspectives on an issue"}
]

# Add table header
pdf.set_font("Arial", 'B', 12)
pdf.cell(40, 10, "Section", 1)
pdf.cell(30, 10, "Questions", 1)
pdf.cell(30, 10, "Marks", 1)
pdf.cell(40, 10, "Negative Marking", 1)
pdf.cell(30, 10, "Time (min)", 1)
pdf.ln()

# Add table content
pdf.set_font("Arial", '', 12)
for sec in sections:
    pdf.cell(40, 10, sec["name"], 1)
    pdf.cell(30, 10, str(sec["questions"]), 1)
    pdf.cell(30, 10, str(sec["marks"]), 1)
    pdf.cell(40, 10, sec["negative"], 1)
    pdf.cell(30, 10, str(sec["time_min"]), 1)
    pdf.ln()
    # Add content description
    pdf.multi_cell(0, 8, "Content: " + sec["content"])
    pdf.ln(2)

# Total summary
pdf.set_font("Arial", 'B', 12)
pdf.ln(5)
pdf.multi_cell(0, 8, "Total Questions (excluding essay): 215\nTotal Time (excluding essay): 175 minutes (~2 hours 55 minutes)")

# Save PDF
pdf.output("ACT_Exam_Overview.pdf")
print("PDF generated successfully!")