Skip to content

Draw a signature field's box - #114

Merged
bobsingor merged 1 commit into
embedpdf/mainfrom
embedpdf/feature/signature-field-box
Nov 4, 2026
Merged

bobsingor merged 1 commit into
embedpdf/mainfrom
embedpdf/feature/signature-field-box

Conversation

@bobsingor

@bobsingor bobsingor commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

A signature field's widget had no drawing until a signature was drawn into it. EPDFAnnot_GenerateFormFieldAP returned false for /FT /Sig and for a widget in no field, and attaching a widget to a signature field baked nothing. The field's /MK colours and /BS were written but never drawn, so a viewer offered a background and a border that never showed. Acrobat's signature field properties have the same four settings (border colour, fill colour, line thickness, line style), and Acrobat draws the empty field with them.

Now:

  • CPDF_AppearanceGenerator::GenerateBoxFormAP draws a widget that shows only its box: its background (/MK /BG) and border (/MK /BC, /BS), as a text field draws them, as a new normal appearance stream. It makes a new stream, as a check box's generator does, because the old /N may be another widget's too, or a drawing someone placed in this one.
  • The text field's box moved into WriteFieldBox, which both use. The text field's output is unchanged.
  • EPDFAnnot_GenerateFormFieldAP draws the box for a /Sig widget and for a widget in no field. It replaces whatever the widget shows, a signature's mark included. Keeping a mark is the caller's decision: the engine never calls it on a widget with a mark in it.
  • EPDFForm_AttachWidget bakes the box for a signature field (family 7), as it bakes every other family.
  • EPDFAnnot_GenerateFormFieldAP refuses an annotation that isn't a widget. A non-widget has no /FT, so with the no-field branch it would otherwise get a box.

RegenerateFieldAppearances and the repair bake still skip signature fields.

The engine side is embedpdf/embed-pdf-viewer#982: it decides when to draw, and locks a field's style once a mark is in it. Pin this there after release.

Tests

  • New embedder tests, recorded as layer-mode writers:

    • AttachToSignatureFieldDrawsItsBox (7 objects): the box in the field's /MK colours.
    • SignatureFieldBoxRedrawsInItsNewStyle (8): an empty box, then the new background after a restyle.
    • WidgetInNoFieldDrawsItsBox (3).
    • GenerateFormFieldAPRefusesAnotherSubtype (2): a square gets no appearance.

    In layer mode the four pass, with no unknown writers.

  • On macOS:

    • Embedder suite: 1,773 pass and 12 fail. The same 12 fail without the change, built from eeac787c0: progressive render, text render, RenderHelloWorldWithFlags and CaptionAppearanceGolden. RenderFormsWithPause is off by the same 19 pixels in both.
    • Unit tests: all 1,320 pass.
    • Pixel tests: 51 fail and 2 surprise, and the base fails the same ones by the same pixels.
  • Linux CI hasn't run yet.

A signature field's widget, and a widget in no field, now have a drawing:
their background and border, as a text field draws them. Attaching a
widget to a signature field bakes it, and EPDFAnnot_GenerateFormFieldAP
redraws it. EPDFAnnot_GenerateFormFieldAP refuses an annotation that is
not a widget.
@bobsingor
bobsingor merged commit 4346c51 into embedpdf/main Nov 4, 2026
1 check passed
@bobsingor
bobsingor deleted the embedpdf/feature/signature-field-box branch November 4, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant