GodsDevProject's picture
Create foia_pdf.py
5b1b62c verified
# foia_pdf.py
from reportlab.lib.pagesizes import LETTER
from reportlab.pdfgen import canvas
from datetime import datetime
from typing import Dict
import os
import uuid
OUTPUT_DIR = "generated_pdfs"
os.makedirs(OUTPUT_DIR, exist_ok=True)
def generate_foia_appeal_pdf(record: Dict) -> str:
"""
Generates a FOIA appeal draft PDF.
This does NOT submit anything to any agency.
"""
filename = f"foia_appeal_{uuid.uuid4().hex}.pdf"
path = os.path.join(OUTPUT_DIR, filename)
c = canvas.Canvas(path, pagesize=LETTER)
width, height = LETTER
text = c.beginText(40, height - 50)
text.setFont("Times-Roman", 11)
text.textLine(f"FOIA Appeal Draft")
text.textLine("")
text.textLine(f"Date: {datetime.utcnow().strftime('%Y-%m-%d')}")
text.textLine("")
text.textLine(f"Agency: {record.get('agency')}")
text.textLine(f"Subject: {record.get('subject')}")
text.textLine("")
text.textLine("To Whom It May Concern,")
text.textLine("")
text.textLine(
"This letter serves as a formal appeal regarding the handling of a "
"Freedom of Information Act (FOIA) request."
)
text.textLine("")
text.textLine(
"The requested materials concern publicly released or previously "
"acknowledged records. Disclosure would contribute significantly "
"to public understanding of government operations."
)
text.textLine("")
text.textLine("Request Description:")
text.textLine(record.get("description", ""))
text.textLine("")
text.textLine(
"This appeal is submitted in good faith for journalistic, academic, "
"or public-interest review."
)
text.textLine("")
text.textLine("Sincerely,")
text.textLine("FOIA Declassified Document Search")
text.textLine("")
text.textLine("—")
text.textLine(
"Disclaimer: This document is a draft generated for reference only. "
"It does not constitute legal advice and does not submit a request "
"to any agency."
)
c.drawText(text)
c.showPage()
c.save()
return path