from fpdf import FPDF
# Replacing problematic character – with - for PDF compatibility
def clean_text(text):
  return text.replace("–", "-")
# Create PDF
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
# Title
pdf.set_font("Arial", style='B', size=14)
pdf.cell(200, 10, txt=clean_text("CS506 Midterm Important Topics - Short & Easy Answers (Roman
English)"), ln=True, align='C')
pdf.ln(10)
pdf.set_font("Arial", size=12)
# Cleaned content
content = [
  ("HTML Tags:", [
        "`<a>` tag: Link banane ke liye use hota hai. Example: <a href='page.html'>Click Here</a>",
        "`<img>` tag: Image show karne ke liye use hota hai. Example: <img src='image.jpg' alt='image'>",
   "`<form>` tag: Form banane ke liye jisme user input deta hai. Example: <form action='submit.php'
method='post'>",
    "`<input>` tag: Form ke andar data lene ke liye hota hai jaise text, radio, checkbox. Example: <input
type='text' name='username'>"
  ]),
  ("CSS Properties:", [
        "color: Text ka rang change karta hai. Example: color: red;",
        "font-size: Text ka size set karta hai. Example: font-size: 16px;",
        "margin: Box ke bahar ka space deta hai. Example: margin: 10px;",
        "padding: Box ke andar ka space deta hai. Example: padding: 10px;"
  ]),
  ("JavaScript Basics:", [
        "Variable: Data ko store karne ka naam hai. Example: let name = 'Ayesha';",
        "Loop: Repeat karne ke liye use hota hai. Example: for(let i=0; i<5; i++) { console.log(i); }",
        "Function: Code ka reusable block. Example: function sayHi() { alert('Hi!'); }"
  ]),
  ("PHP Basics:", [
        "echo: Screen pe output show karta hai. Example: echo 'Hello Ayesha';",
        "Variable: Data store karta hai $ ke sath. Example: $name = 'Ayesha';",
        "Array: Multiple values store karne ka tareeqa. Example: $fruits = array('Apple', 'Banana', 'Mango');"
  ]),
  ("MySQL Queries:", [
        "SELECT: Database se data nikalne ke liye hota hai. Example: SELECT * FROM users;",
   "INSERT: Database me naya data add karne ke liye hota hai. Example: INSERT INTO users(name,
email) VALUES('Ayesha', 'a@email.com');"
  ]),
  ("GET vs POST Methods:", [
        "GET: Data URL me dikhta hai, secure nahi hota. Example: form method='get'",
        "POST: Data hidden hota hai, zyada secure. Example: form method='post'"
  ]),
  ("Cookies vs Sessions:", [
        "Cookies: Client (browser) me store hoti hain.",
        "Sessions: Server pe store hoti hain, zyada secure hoti hain."
  ]),
  ("Client-side vs Server-side Scripting:", [
        "Client-side: Browser pe run hoti hai (HTML, CSS, JavaScript).",
          "Server-side: Server pe run hoti hai (PHP, MySQL)."
    ]),
# Add content
for title, lines in content:
    pdf.set_font("Arial", style='B', size=12)
    pdf.cell(200, 10, txt=clean_text(title), ln=True)
    pdf.set_font("Arial", size=12)
    for line in lines:
          pdf.multi_cell(0, 10, txt="- " + clean_text(line))
    pdf.ln(5)
# Save the PDF
pdf_path = "/mnt/data/CS506_Midterm_Important_Topics_Ayesha.pdf"
pdf.output(pdf_path)
pdf_path