Skip to content

[FEAT]: Support checkbox and radio button field filling in output PDF #229

@utkarshqz

Description

@utkarshqz

📝 Description

FireForm currently fills text-based PDF fields correctly but provides no support for checkbox or radio button field types. These fields are left blank in the output PDF regardless of what the LLM extracts from the transcript.

This is a gap in the core PDF filling pipeline — the extraction layer already works correctly, making this a targeted and isolated fix in src/filler.py.

💡 Rationale

Emergency response forms commonly include checkbox and radio button fields — for example:

  • "Was medical assistance required?" → checkbox
  • "Incident type: Fire / Medical / Hazmat" → radio button

Leaving these blank produces incomplete, unusable output PDFs that fail real-world filing requirements. Fixing this is essential for FireForm to serve its stated purpose of automating form completion for firefighters and emergency responders.

🛠️ Proposed Solution

In src/filler.py, add field-type detection and value mapping for /Btn field types:

# Detect field type
field_type = field.get("/FT")

if field_type == "/Btn":
    # Map extracted string value to PDF boolean value
    val = str(value).strip().lower()
    if val in ("yes", "true", "1", "checked"):
        field.update(pdfrw.PdfDict(V=pdfrw.PdfName("Yes"), AS=pdfrw.PdfName("Yes")))
    else:
        field.update(pdfrw.PdfDict(V=pdfrw.PdfName("Off"), AS=pdfrw.PdfName("Off")))

✅ Acceptance Criteria

  • Checkbox fields correctly set to /Yes or /Off based on transcript content
  • Radio button group selections correctly applied
  • Existing text field behavior is completely unchanged
  • Unit tests cover checkbox (/Yes) and checkbox (/Off) cases
  • Unit tests cover radio button selection

📌 Additional Context

  • The LLM extraction layer (src/llm.py) already extracts boolean and choice values correctly — this issue is purely a filler.py mapping problem
  • pdfrw supports /Btn field type natively — no new dependencies required
  • Related to the broader goal of full PDF field type coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions