Repository navigation
Draw a static form field in its CSS colour, background and border (#432) - #442
Merged
jakejackson1 merged 4 commits intoSep 23, 2026
Merged
Conversation
This was referenced Sep 23, 2026
A field drawn into the page, with active forms off, always had a near-white fill, black text and a 0.2mm border in the colour already set. The form tags now record the field's background and border, read from the BORDER-TOP shorthand the cascade folds the border into, whether or not forms are active, and Form draws text inputs, text areas, selects, buttons, checkboxes and radio buttons with them, keeping the defaults for what the CSS leaves unset. The disabled and read-only greys still win, and a border of style none or no width is not drawn. An active field's /MK /BC now also follows a border colour given in the border shorthand, which only the border-color longhand reached before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…atic field's colours in one place Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
form-fields-static draws its styled field in dark red on pale yellow inside a blue border, and form-fields-active and form-fields-pdfa take that blue as the widget's border colour. The page-break-avoid fixtures draw their fields' grey CSS border. Rasterised against the base branch, nothing else changes; 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>
jakejackson1
force-pushed
the
fix/432-static-field-css
branch
from
September 23, 2026 20:47
6185cdf to
2a3430c
Compare
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
…) (#442) * Draw a static form field in its CSS colour, background and border (#432) A field drawn into the page, with active forms off, always had a near-white fill, black text and a 0.2mm border in the colour already set. The form tags now record the field's background and border, read from the BORDER-TOP shorthand the cascade folds the border into, whether or not forms are active, and Form draws text inputs, text areas, selects, buttons, checkboxes and radio buttons with them, keeping the defaults for what the CSS leaves unset. The disabled and read-only greys still win, and a border of style none or no width is not drawn. An active field's /MK /BC now also follows a border colour given in the border shorthand, which only the border-color longhand reached before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Share BorderMerger's border defaults with the form tags, and set a static field's colours in one place Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Say what the static field style helpers do more plainly Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Refresh the form snapshots for a field's CSS colours and border form-fields-static draws its styled field in dark red on pale yellow inside a blue border, and form-fields-active and form-fields-pdfa take that blue as the widget's border colour. The page-break-avoid fixtures draw their fields' grey CSS border. Rasterised against the base branch, nothing else changes; 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>
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
…) (#442) * Draw a static form field in its CSS colour, background and border (#432) A field drawn into the page, with active forms off, always had a near-white fill, black text and a 0.2mm border in the colour already set. The form tags now record the field's background and border, read from the BORDER-TOP shorthand the cascade folds the border into, whether or not forms are active, and Form draws text inputs, text areas, selects, buttons, checkboxes and radio buttons with them, keeping the defaults for what the CSS leaves unset. The disabled and read-only greys still win, and a border of style none or no width is not drawn. An active field's /MK /BC now also follows a border colour given in the border shorthand, which only the border-color longhand reached before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Share BorderMerger's border defaults with the form tags, and set a static field's colours in one place Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Say what the static field style helpers do more plainly Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Refresh the form snapshots for a field's CSS colours and border form-fields-static draws its styled field in dark red on pale yellow inside a blue border, and form-fields-active and form-fields-pdfa take that blue as the widget's border colour. The page-break-avoid fixtures draw their fields' grey CSS border. Rasterised against the base branch, nothing else changes; 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>
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #432
What changed
With
useActiveFormsoff, a form field drawn into the page now takes its CSScolor,background-colorand border. Before this, every field had a near-white fill, black text and a 0.2mm border in whatever stroke colour was already set.Tag::formFieldStyle()records the field'sbackground-col,border-col,border-width(mm) andborder-styleinto$objattr. It does this forInput(text, password, buttons, checkbox, radio),TextAreaandSelect(throughselectoption, the same way asCOLOR), whether or not forms are active.InputandTextAreareadBORDER-TOP-COLORand only insideif ($this->mpdf->useActiveForms). That property is only set when theborder-colorlonghand is written.BorderMergerfolds abordershorthand intoBORDER-TOP, soborder: 0.5mm solid #0000ffnever reached the field.formFieldStyle()now readsBORDER-TOPinstead.BorderMergerfills the missing parts with0px none #000000when only a longhand is given, e.g.border-coloron its own. Those filled-in parts are ignored, so the longhand changes only its own part of mPDF's default border. The fill values are nowBorderMerger::DEFAULTS, a single constant both classes use.Form::print_ob_*). Text inputs, text areas, selects, buttons, checkboxes and radio buttons now draw with the CSS fill, stroke colour, line width and text colour. Anything the CSS leaves unset keeps today's defaults.noneorhidden, or of zero width, is not drawn: the field is filled only./MK /BCalready came fromborder-col, so it now follows a border colour given in the shorthand too. That is part of An active form field ignores its CSS border and uses the default colour and width #431. The rest of An active form field ignores its CSS border and uses the default colour and width #431 (the/BSwidth and style, the choice field, and the appearance streams) is in the stacked PR.Snapshots
Each refresh is its own commit, and each was checked by rasterising with
pdftoppmagainst the old fixture.form-fields-static: only the "Styled" row changed. It now draws dark red text on pale yellow inside a 0.5mm blue border, where before it had black text in a thin black box.form-fields-active,form-fields-pdfa: the styled field's/MK /BCand its appearance border change from the default0.6 0.6 0.72to the CSS#0066cc. Nothing else changed apart from the PDF/A document ID.page-break-avoid-forms,page-break-avoid-references: these declareinput, select, textarea { border: 0.2mm solid #404040 }. The active text fields, text areas and buttons now draw that grey border instead of the default blue-grey. The select does not yet, becauseSetFormChoiceignoresborder-col(fixed in the An active form field ignores its CSS border and uses the default colour and width #431 PR).Verification
tests/Mpdf/StaticFieldStyleTest.php(16 tests) covers:1.417 w,0 0 1 RG,1 1 0.8 rg, andre Bfollowed by the text in0.753 0 0 rg;border-color,border-widthandborder-stylelonghands on their own;none,0,border-width: 0andhidden, drawn withre fand no stroke;composer test: 3761 tests, 5 skipped (pre-existing), no failures.composer test -- --group=snapshot: 88 OK.composer test -- --group=conformance(veraPDF): 26 OK.composer cs: clean. PHPStan 2.2: no errors.php -lunder PHP 5.6: clean.Limits and follow-ups
noneandhiddenis drawn solid. Dashed, dotted, inset and the rest are not imitated.coloronly when one is set.Tag::formFieldStyle(),BorderMerger::DEFAULTSand theForm::print_ob_*static branches apply tompdf/mpdfdevelopmentas they are.🤖 Generated with Claude Code