Skip to content

Give an active form field the width and style of its CSS border (#431), restoring #445 - #469

Merged
jakejackson1 merged 1 commit into
feature/pdfa-2-conformancefrom
fix/431-active-field-border-restore
Sep 23, 2026
Merged

jakejackson1 merged 1 commit into
feature/pdfa-2-conformancefrom
fix/431-active-field-border-restore

Conversation

@jakejackson1

Copy link
Copy Markdown
Member

Fixes #431

Restores #445, which was merged into the wrong branch. #442 merged fix/432-static-field-css into feature/pdfa-2-conformance first. #445, stacked on #442, was then merged into fix/432-static-field-css (c675d3f), so its changes never reached feature/pdfa-2-conformance. This PR is that squash commit cherry-picked onto feature/pdfa-2-conformance. #442's squash (9581528) has the same content as the commit #445 was merged on, so the cherry-pick applied cleanly and the resulting tree is identical to c675d3f. Nothing changed from what was reviewed in #445.

The description below is #445's, with the verification counts refreshed.

What changed

  • /BS /W now comes from the CSS border width in points. /BS /S comes from its style:
    • solid → /S
    • dashed → /D /D [3]
    • dotted → /D /D [1]
    • inset → /I
    • outset → /B
    • double, groove and ridge → /S, since PDF has no equivalent.
  • border: none or border-style: hidden gives /W 0, and /MK leaves out /BC, because a viewer that redraws the field draws a border wherever /BC is present. The same applies to text and choice fields left at SetFormBorderWidth('0').
  • Give every active form widget its own appearance, and ask the viewer to redraw only text it cannot shape (#348, #59) #387's appearance streams now draw the same border: its colour, its width (with the text inset by it, as before), and the dash pattern for a dashed or dotted style. Colours still go through appearanceColor(), so they follow the output intent. /MK is also CMYK when the document is restricted to CMYK.
  • Fields covered: text inputs, textareas, selects (combo and list), and submit, reset and JS buttons. SetFormChoice also takes the select's CSS border-color and background-color now; before, it ignored them.
  • Implementation:
    • Form::activeBorder($objattr) turns the recorded CSS into ['W' => …, 'S' => …].
    • SetFormText, SetFormChoice, SetFormButton and the reset, submit and JS button wrappers take it as a new trailing optional $border array. When the array leaves W or S out, the existing form_border_* or form_button_border_* default is used for it.
    • SetFormChoice also gains the $background_col and $border_col parameters the others already had.

Snapshots

Refreshed in their own commit and checked by rasterising with pdftoppm:

  • form-fields-active and form-fields-pdfa: the "Styled" field's border goes from 1pt to 0.5mm (1.417pt) in both /BS and the appearance. Otherwise only the PDF/A document ID changes.
  • page-break-avoid-forms and page-break-avoid-references: these set border: 0.2mm solid #404040 on fields. The active fields now draw that thinner 0.567pt border, and the select picks up the grey border colour too.

Verification

  • tests/Mpdf/ActiveFieldBorderTest.php has 18 tests:
    • the issue's input: /BS << /W 1.417 /S /S >>, /MK <</BC [ 0 0 1 ] /BG [ 1 1 0.8 ], and an appearance stroking 0 0 1 RG 1.417 w;
    • each field kind;
    • the defaults;
    • every style mapping, including the dash in the appearance;
    • none and hidden: /W 0, no /BC, no stroke;
    • the longhands on their own;
    • CMYK colours under PDF/A with restrictColorSpace 3.
  • composer test: 3828 tests, 5 skipped (these were already skipped before this change), no failures.
  • composer test -- --group=snapshot: 89 OK.
  • composer test -- --group=conformance (veraPDF): 29 OK.
  • A PDF/A-2B document with a dashed text field, a borderless text field, an inset select with a background, a dotted submit button and a 2pt solid textarea passes veraPDF 2b.
  • composer cs is clean. PHPStan 2.2.15 reports no errors. php -l under PHP 5.6 is clean.
  • When Give an active form field the width and style of its CSS border (#431) #445 was rebased onto Shrink a form field's text to fit its field instead of cutting it off (#433) #441, SetJSButton()'s moved SetFormButton() call needed $border passed through. The button case of ActiveFieldBorderTest fails without it.

Limits and follow-ups

🤖 Generated with Claude Code

#445)

* Give an active form field the width and style of its CSS border (#431)

An active text field, text area, select or button always had a 1pt solid
border in /BS, whatever its CSS said. The border width, in points, and style
the form tags record now reach /BS and the appearance: solid, dashed, dotted,
inset and outset become /S, /D (dashed in the appearance too), /I and /B, and
a border of style none has no width and no /BC, which a viewer would draw
regardless. A select also takes its CSS border and background colours, which
it ignored before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Share the active field colour fallback and the no-border rules between the field kinds

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Say what the active border helpers do more plainly

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Refresh the active form snapshots for the CSS border width and the select's border colour

form-fields-active and form-fields-pdfa write the styled field's 0.5mm border in /BS and draw it
in its appearance. page-break-avoid-forms and page-break-avoid-references draw their fields'
0.2mm CSS border, thinner than the 1pt default, and their select takes its grey colour too.
Rasterised against #432's fixtures only those borders change; against this branch before its
rebase onto #441, only the maxlength field differs, which #441 draws whole in a smaller font.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Cherry-picked from c675d3f. PR #445 was merged into fix/432-static-field-css after #442 had
already merged that branch into feature/pdfa-2-conformance, so it never reached this branch.
@jakejackson1 jakejackson1 added bug Something isn't working create-upstream-pr labels Sep 23, 2026
@jakejackson1
jakejackson1 merged commit 8148660 into feature/pdfa-2-conformance Sep 23, 2026
29 checks passed
jakejackson1 added a commit that referenced this pull request Sep 23, 2026
#445) (#469)

* Give an active form field the width and style of its CSS border (#431)

An active text field, text area, select or button always had a 1pt solid
border in /BS, whatever its CSS said. The border width, in points, and style
the form tags record now reach /BS and the appearance: solid, dashed, dotted,
inset and outset become /S, /D (dashed in the appearance too), /I and /B, and
a border of style none has no width and no /BC, which a viewer would draw
regardless. A select also takes its CSS border and background colours, which
it ignored before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Share the active field colour fallback and the no-border rules between the field kinds

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Say what the active border helpers do more plainly

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Refresh the active form snapshots for the CSS border width and the select's border colour

form-fields-active and form-fields-pdfa write the styled field's 0.5mm border in /BS and draw it
in its appearance. page-break-avoid-forms and page-break-avoid-references draw their fields'
0.2mm CSS border, thinner than the 1pt default, and their select takes its grey colour too.
Rasterised against #432's fixtures only those borders change; against this branch before its
rebase onto #441, only the maxlength field differs, which #441 draws whole in a smaller font.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Cherry-picked from c675d3f. PR #445 was merged into fix/432-static-field-css after #442 had
already merged that branch into feature/pdfa-2-conformance, so it never reached this branch.
jakejackson1 added a commit that referenced this pull request Sep 23, 2026
#445) (#469)

* Give an active form field the width and style of its CSS border (#431)

An active text field, text area, select or button always had a 1pt solid
border in /BS, whatever its CSS said. The border width, in points, and style
the form tags record now reach /BS and the appearance: solid, dashed, dotted,
inset and outset become /S, /D (dashed in the appearance too), /I and /B, and
a border of style none has no width and no /BC, which a viewer would draw
regardless. A select also takes its CSS border and background colours, which
it ignored before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Share the active field colour fallback and the no-border rules between the field kinds

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Say what the active border helpers do more plainly

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Refresh the active form snapshots for the CSS border width and the select's border colour

form-fields-active and form-fields-pdfa write the styled field's 0.5mm border in /BS and draw it
in its appearance. page-break-avoid-forms and page-break-avoid-references draw their fields'
0.2mm CSS border, thinner than the 1pt default, and their select takes its grey colour too.
Rasterised against #432's fixtures only those borders change; against this branch before its
rebase onto #441, only the maxlength field differs, which #441 draws whole in a smaller font.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Cherry-picked from c675d3f. PR #445 was merged into fix/432-static-field-css after #442 had
already merged that branch into feature/pdfa-2-conformance, so it never reached this branch.
@jakejackson1
jakejackson1 deleted the fix/431-active-field-border-restore branch September 30, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working create-upstream-pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant