Skip to content

fix(signatures): render logo behind text and fit visible signature text in both dimensions #606

Description

@bzsanti

Problem

The logo in a visible digital signature occupies a separate column instead of acting as a watermark behind the text. Enabling it reduces the text area to 58% of the rectangle, even when the logo itself is small. Long signer names and additional text can therefore fail to fit inside a reasonably large signature rectangle.

Studio reports: The signature text does not fit. Enlarge the rectangle, disable the logo or shorten the additional text. Its preflight check mirrors the engine's layout. In the engine itself, overflowing text is clipped or omitted rather than wrapped to the available width.

Expected behavior: a translucent logo behind the text, with the text using the same available area whether the logo is enabled or disabled. Text should fit the rectangle in both dimensions without losing content.

Evidence

Observed while testing Studio 0.1.13 with oxidize-pdf 5.1.1 pinned to 6bace0a868cad360b16a16f8657a4eac49c94689.

Source: visible signature appearance generation.

The current implementation:

  • Positions the image toward the right using width * 0.36 as its maximum width.
  • Restricts the text area to width * 0.58 when a watermark exists.
  • Chooses the font size from the height and original line count only, clamped to 6–12 points.
  • Does not wrap long lines or adapt the font size to their width.
  • Clips horizontal overflow and stops writing lines when their baseline drops below the margin. The height estimate also does not account consistently for the 1.25 line spacing.

Reproduction

  1. Prepare a visible signature with a 300 × 100 point rectangle, a signing date and a signer name such as MARIA DEL CARMEN FERNANDEZ.
  2. Supply a SignatureWatermark with a nonzero opacity.
  3. Compare the generated appearance with the same text and rectangle without the watermark.
  4. Increase the name or additional text length while keeping enough total rectangle area for wrapped lines.

The watermark reserves a separate column. The engine never wraps the text; Studio may reject the appearance before signing because its matching preflight detects the overflow.

Acceptance criteria

  • Render the logo behind the text, centered within the rectangle, preserving its aspect ratio and configured opacity.
  • Keep text layout identical with and without the watermark: the logo must not reserve a column.
  • Wrap long names and additional text and fit them to the available width and height, including margins and line spacing, with a readable minimum font size.
  • If the complete text cannot fit at the minimum size, return an explicit layout error before accessing the signing key. Do not truncate, clip or silently drop text.
  • Use the same layout calculation for validation and PDF generation, so consuming applications can remove their duplicated size calculations.
  • Cover watermark on/off, long names, multiple additional lines, and rectangles that genuinely cannot fit the text with regression tests. Verify that the final appearance remains covered by the digital signature.

The user requested tracking this engine correction as an issue. No engine changes or publication are part of this report.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions