Skip to content

[FEAT]: Auto-scale font size according to length so words dont get cut off #290

@Cubix33

Description

@Cubix33

📝 Description

When the AI writes a very long name or a long sentence, it doesn't fit in the small boxes on the PDF. Currently, the extra words just get cut off at the edge of the box. This feature will make the font "shrink" automatically so the whole sentence stays inside the box.

💡 Rationale

In emergency reporting, names, addresses, or even other fields can be very long and incident descriptions can be detailed. If the text is cut off, the legal document is incomplete. We need the PDF to be smart enough to resize the text so every word is readable.

🛠️ Proposed Solution

We will use a "Magic Zero" trick in the PDF code. If we tell the PDF that the font size is 0, the PDF reader (like Chrome or Adobe) will automatically shrink the text until it fits the box perfectly.

  • Logic change in src/filler.py: Add a check to see if the text is long (>20 characters).

  • Update annot.DA: Change the font setting to /Helv 0 Tf. This triggers the "Auto-Size" mode.

  • Clear Appearance (annot.AP): Tell the PDF to redraw the text so the new size shows up immediately.

✅ Acceptance Criteria

  • Long Text Test: If we input a 50-character name, it should appear small but fully visible inside the box.

  • Short Text Test: Short words like "Fire" should stay at the normal, large font size.

📌 Additional Context

This is a standard feature in professional PDF software. Instead of us doing hard math to guess the font size, we are letting the PDF format do the work for us.

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