CoolFace
Apppublic

GodsDevProject/FOIA_Doc_Search

sourceHugging Facemitupdated 9mo agoView on Hugging Face
1likes
foia_pdf.py70 linesDownload Raw Back to root
1# foia_pdf.py2from reportlab.lib.pagesizes import LETTER3from reportlab.pdfgen import canvas4from datetime import datetime5from typing import Dict6import os7import uuid8 9OUTPUT_DIR = "generated_pdfs"10os.makedirs(OUTPUT_DIR, exist_ok=True)11 12 13def generate_foia_appeal_pdf(record: Dict) -> str:14    """15    Generates a FOIA appeal draft PDF.16    This does NOT submit anything to any agency.17    """18 19    filename = f"foia_appeal_{uuid.uuid4().hex}.pdf"20    path = os.path.join(OUTPUT_DIR, filename)21 22    c = canvas.Canvas(path, pagesize=LETTER)23    width, height = LETTER24 25    text = c.beginText(40, height - 50)26    text.setFont("Times-Roman", 11)27 28    text.textLine(f"FOIA Appeal Draft")29    text.textLine("")30    text.textLine(f"Date: {datetime.utcnow().strftime('%Y-%m-%d')}")31    text.textLine("")32    text.textLine(f"Agency: {record.get('agency')}")33    text.textLine(f"Subject: {record.get('subject')}")34    text.textLine("")35    text.textLine("To Whom It May Concern,")36    text.textLine("")37    text.textLine(38        "This letter serves as a formal appeal regarding the handling of a "39        "Freedom of Information Act (FOIA) request."40    )41    text.textLine("")42    text.textLine(43        "The requested materials concern publicly released or previously "44        "acknowledged records. Disclosure would contribute significantly "45        "to public understanding of government operations."46    )47    text.textLine("")48    text.textLine("Request Description:")49    text.textLine(record.get("description", ""))50    text.textLine("")51    text.textLine(52        "This appeal is submitted in good faith for journalistic, academic, "53        "or public-interest review."54    )55    text.textLine("")56    text.textLine("Sincerely,")57    text.textLine("FOIA Declassified Document Search")58    text.textLine("")59    text.textLine("—")60    text.textLine(61        "Disclaimer: This document is a draft generated for reference only. "62        "It does not constitute legal advice and does not submit a request "63        "to any agency."64    )65 66    c.drawText(text)67    c.showPage()68    c.save()69 70    return path