Share via

Myplanforsoap

Sami Ullah 0 Reputation points
2025-08-18T18:15:18.43+00:00

from reportlab.lib.pagesizes import A4

from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer

from reportlab.lib import colors

from reportlab.lib.styles import getSampleStyleSheet

File path (yahan aap apni PC location de sakte ho, jaise D:/ ya Desktop)

file_path = "SOPE_2028_Weekly_Study_Plan_with_Checkboxes.pdf"

doc = SimpleDocTemplate(file_path, pagesize=A4)

styles = getSampleStyleSheet()

elements = []

Title

title = Paragraph("SOPE 2028 – Weekly Study Plan (Science/Engineering Background)", styles['Title'])

elements.append(title)

elements.append(Spacer(1, 12))

Table data with checkboxes

data = [

["Day", "Subjects & Activities", "Done"],

["Monday", "Maths & Stats (2 hrs): Algebra, Probability, Calculus\nEssay (30 min): Outline practice", "□"],

["Tuesday", "International Relations (2 hrs): Theories, Cold War, Current IR Issues\nEnglish Grammar (30 min): Precis + Comprehension", "□"],

["Wednesday", "General Knowledge (2 hrs): Pakistan Affairs + Islamiat\nEveryday Science (30 min): Short notes", "□"],

["Thursday", "Maths & Stats (2 hrs): Past paper questions, timed solving\nOffice Management-I (30 min): HRM / IT / Rules", "□"],

["Friday", "International Relations (2 hrs): Foreign Policy, UN, Current Affairs\nEssay (30 min): Write one full essay", "□"],

["Saturday", "Office Management-II (2 hrs): Civil Servants Act, Rules of Business, PPRA\nEnglish (30 min): Grammar, vocab, correction", "□"],

["Sunday", "Morning (2 hrs): Weekly revision\nEvening: Attempt 1 past paper (exam conditions)", "□"],
```]

# Table style

table = Table(data, colWidths=[80, 350, 50])

table.setStyle(TableStyle([

('BACKGROUND', (0, 0), (-1, 0), colors.HexColor("#4F81BD")),

('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),

('ALIGN', (0, 0), (-1, -1), 'LEFT'),

('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),

('FONTSIZE', (0, 0), (-1, 0), 12),

('FONTSIZE', (0, 1), (-1, -1), 10),

('BOTTOMPADDING', (0, 0), (-1, 0), 10),

('BACKGROUND', (0, 1), (-1, -1), colors.beige),

('GRID', (0, 0), (-1, -1), 0.5, colors.black),


elements.append(table)

elements.append(Spacer(1, 20))

# Monthly goals with checkboxes

monthly_goals = Paragraph("""

<b>📌 Monthly Goals</b><br/>

□ 1 Essay per week → 4 essays / month<br/>

□ Maths & Stats practice → 30–40 questions per month<br/>

□ IR / Economy → 1 major topic per week<br/>

□ GK / Islamiat / Science → Daily 15–20 min MCQ prep<br/>

□ Every 3 months → Full mock exam (compulsory + optional)

""", styles['Normal'])

elements.append(monthly_goals)

doc.build(elements)

print(f"PDF generated: {file_path}")
Community Center | Not monitored
0 comments No comments

3 answers

Sort by: Most helpful
  1. BryceSor 5,170 Reputation points Volunteer Moderator
    2025-08-18T22:27:54.33+00:00

    Hi Sami Ullah,

    This script is based on your post so I hope it helps.

    from reportlab.pdfgen import canvas
    from reportlab.lib.pagesizes import A4
    from reportlab.lib.units import mm
    import argparse
    import os
    
    def generate_study_plan_pdf(file_path):
        c = canvas.Canvas(file_path, pagesize=A4)
        width, height = A4
    
        # Title
        c.setFont("Helvetica-Bold", 16)
        c.drawString(30, height - 50, "SOPE 2028 – Weekly Study Plan (Science/Engineering Background)")
    
        # Table headers
        c.setFont("Helvetica-Bold", 12)
        c.drawString(30, height - 80, "Day")
        c.drawString(100, height - 80, "Subjects & Activities")
        c.drawString(450, height - 80, "Done")
    
        # Weekly data
        study_data = [
            ("Monday", "Maths & Stats (2 hrs): Algebra, Probability, Calculus\nEssay (30 min): Outline practice"),
            ("Tuesday", "International Relations (2 hrs): Theories, Cold War, Current IR Issues\nEnglish Grammar (30 min): Precis + Comprehension"),
            ("Wednesday", "General Knowledge (2 hrs): Pakistan Affairs + Islamiat\nEveryday Science (30 min): Short notes"),
            ("Thursday", "Maths & Stats (2 hrs): Past paper questions, timed solving\nOffice Management-I (30 min): HRM / IT / Rules"),
            ("Friday", "International Relations (2 hrs): Foreign Policy, UN, Current Affairs\nEssay (30 min): Write one full essay"),
            ("Saturday", "Office Management-II (2 hrs): Civil Servants Act, Rules of Business, PPRA\nEnglish (30 min): Grammar, vocab, correction"),
            ("Sunday", "Morning (2 hrs): Weekly revision\nEvening: Attempt 1 past paper (exam conditions)")
        ]
    
        y = height - 110
        for i, (day, activities) in enumerate(study_data):
            c.setFont("Helvetica", 10)
            c.drawString(30, y, day)
            text_obj = c.beginText(100, y)
            for line in activities.split('\n'):
                text_obj.textLine(line)
            c.drawText(text_obj)
    
            # Checkbox
            c.acroForm.checkbox(
                name=f"done_{i}",
                tooltip="Mark as done",
                x=450,
                y=y - 2,
                size=12,
                borderColor=None,
                fillColor=None,
                textColor=None,
                forceBorder=False
            )
    
            y -= 50
    
        # Monthly Goals
        c.setFont("Helvetica-Bold", 12)
        c.drawString(30, y - 20, "📌 Monthly Goals")
    
        goals = [
            "1 Essay per week → 4 essays / month",
            "Maths & Stats practice → 30–40 questions per month",
            "IR / Economy → 1 major topic per week",
            "GK / Islamiat / Science → Daily 15–20 min MCQ prep",
            "Every 3 months → Full mock exam (compulsory + optional)"
        ]
    
        y -= 50
        for i, goal in enumerate(goals):
            c.drawString(50, y, goal)
            c.acroForm.checkbox(
                name=f"goal_{i}",
                tooltip="Goal completed",
                x=30,
                y=y - 2,
                size=12
            )
            y -= 30
    
        c.save()
        print(f"✅ PDF generated: {file_path}")
    
    # CLI support
    if __name__ == "__main__":
        parser = argparse.ArgumentParser(description="Generate SOPE 2028 Weekly Study Plan PDF")
        parser.add_argument("--output", type=str, default="SOPE_2028_Weekly_Study_Plan_with_Checkboxes.pdf",
                            help="Path to save the PDF file")
        args = parser.parse_args()
    
        output_path = os.path.abspath(args.output)
        generate_study_plan_pdf(output_path)
    
    

    How to Use

    Save the script as generate_sope_plan.py.

    Run it from the terminal: If you have any issues double check all your location and for typing errors.

    python generate_sope_plan.py --output "C:/Users/YourName/Desktop/SOPE_2028_Plan.pdf"
    
    

    Was this answer helpful?

    0 comments No comments

  2. Restee Miranda 14,035 Reputation points Independent Advisor
    2025-08-18T18:55:17.0133333+00:00

    Hi Sami,

    Thanks for reaching out to the Community. It seems that you were trying to print out a PDF file with the question you posted here. You can do it by pasting and formatting it in excel or word and then save it as pdf.

    If you needed more help, please feel free to reply to this thread.

    All the best,

    Res

    Was this answer helpful?

    0 comments No comments

  3. Sami Ullah 0 Reputation points
    2025-08-18T18:15:44.0766667+00:00

    Make a pdf file

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.