Skip to content

[FEAT]: Support for PDF Checkbox and Radio Button Widgets (/Btn) #142

@Cubix33

Description

@Cubix33

📝 Description

Currently, filler.py treats all PDF annotations as text fields (/Tx). It attempts to write string values directly to annot.V and refreshes the appearance with annot.AP = None.

While this works for standard text boxes, it fails for Button widgets (/Btn), such as checkboxes and radio buttons. In the PDF specification, these widgets do not display text; they rely on an Appearance State (/AS) to toggle between "On" and "Off" visual states.

💡 Rationale

[cite_start]Many official forms (like the UC Vaccine Declination statement) rely heavily on checkboxes for legal acknowledgments[cite: 1, 15, 17]. Currently, FireForm cannot "check" these boxes. Instead, it either leaves them blank or attempts to write text into a non-text field, which can lead to document corruption or invisible data.

Adding support for /Btn widgets expands the tool's utility to include virtually all standard government, medical, and legal forms.

🛠️ Proposed Solution

Modify the filling logic in src/filler.py to inspect the Field Type (/FT) of each annotation:

  • If annot.FT == '/Btn', the system should translate the LLM's boolean-like response (Yes/No, True/False) into the correct PDF PdfName.

  • The logic must set both the Value (/V) and the Appearance State (/AS) to the "On" value (standardized as /Yes or /On) to ensure the checkmark is visually rendered.

  • Standard text logic should remain as the fallback for /Tx fields.

  • Logic change in src/filler.py

  • Enhancement to add_response_to_json in src/llm.py to handle boolean mapping.

✅ Acceptance Criteria

  • Interactive checkboxes in a PDF are successfully "checked" (rendered with an X or checkmark) based on the LLM's extraction.
  • The system correctly identifies the difference between a text box and a checkbox.
  • No regression in standard text field filling.

📌 Additional Context

This is a foundational fix for supporting complex forms. [cite_start]I have tested this logic against a modified version of the UC Vaccine Declination form containing checkboxes for the "I am aware of the following facts" section[cite: 9, 10, 15].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions