Skip to content

[e-signature] Text overflow in signature box — drawCertInfo has no lower-bound clipping #21

@Yorizel

Description

@Yorizel

Summary

drawCertInfo starts text at opts.y + opts.height - 20 and decrements by lineHeight = 14 per line with no check that text stays within the signature box. For small signature heights, text overflows below opts.y, placing content outside the designated signature rectangle.

Root Cause

appearance.ts:94:

let textY = opts.y + opts.height - 20;

And subsequent lines:

textY -= lineHeight;        // 14px per line
// ... no lower-bound guard

For height: 40, the box spans [opts.y, opts.y + 40]. Starting at opts.y + 20, then decrementing 14px × 4 lines = 56px total drop, text lands at opts.y - 36 — 36 points below the box floor.

Affected Files

  • libraries/e-signature/src/appearance.ts:94textY initialization
  • libraries/e-signature/src/appearance.ts:104-170 — no bounds check in the text-drawing loop

Evidence

For height: 60, up to 4 text lines are drawn:

Line 1: y = 60 - 20 = 40 above box origin      → inside ✓
Line 2: y = 40 - 14 = 26 above box origin      → inside ✓
Line 3: y = 26 - 14 = 12 above box origin      → inside ✓
Line 4: y = 12 - 14 = -2 above box origin      → OUTSIDE ✗

Suggested Fix

  • Add a lower-bound guard before each page.drawText call:
    if (textY < opts.y) break; // or return — stop drawing outside box
  • Or dynamically scale fontSize and lineHeight based on available box height
  • Add a minimum height to schema (e.g., z.number().min(60)) to ensure the box can accommodate content

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions