Repository navigation
Bring the form field PRs merged into feature/pdfa-2-conformance after #330 into gravitypdf - #470
Merged
Merged
Conversation
…#433) (#441) * Shrink a form field's text to fit its field instead of cutting it off (#433) A text input's value, a combo box's choice and a push button's caption that are too wide for the field are drawn in a smaller font, both into the page and in an active field's appearance. The size scales with the overflow, rounded down to 0.001pt, and goes no lower than half the field's size or 6pt. Past that minimum the text is trimmed to whole characters, found by halving. One rule, fitLine(), serves every case. An active text field or combo box that shrinks is written with /DA 0 Tf so the viewer sizes it too. A push button's /DA names the size its appearance was drawn at. /V, /DV, /Opt and /CA keep the whole text. The static button now shapes its caption through shapeText(), and a static text input measures the value as Cell() draws it, padding shrunk with a shrunk table included. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Drop the isset() on a foreach variable that PHPStan 2.2.15 no longer reports (#451) The baseline ignored "Variable $c in isset() always exists" in Svg.php. PHPStan 2.2.15 stopped reporting it, so the unmatched ignore failed static analysis on gravitypdf and every branch cut from it. $c is always set inside its foreach, so the check goes and the ignore with it, which passes under 2.2.14 and 2.2.15 alike. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…) (#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>
#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.
… a kid (#447) * Write push buttons that share a name as one field with each widget as a kid Same-named submit, reset, script and image buttons were written as separate fields with the same /T, and their script and icon were looked up by name, so the second button's script replaced the first's and was then used up. Each group is now a parent field (/FT /Btn, push-button flag, /T, /Kids) listed in /AcroForm /Fields but in no page's /Annots, and its widgets keep their own action, caption, icon and appearance under a /Parent. Scripts and icons are keyed by the button's form number. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Read the reference lists in the shared button name tests with one helper, and write the push-button flag as the widgets do Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Say what a push button is where the shared button name code asks Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
#441 moved SetJSButton()'s SetFormButton() call below the icon, so that the field knows it shows one, and #447 keyed the icon by $this->formCount, which is the button's number only once SetFormButton() has counted it. Merged together, each icon went to the form before it: the widget lost its icon, the object count reserved one that was never written, and SetFormButton() still looked the icon up by name. The icon is now kept under the number the button is about to get, and SetFormButton() looks for it there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
force-pushed
the
forward/pdfa-2-form-fields
branch
from
September 23, 2026 21:58
9c01d2d to
736154f
Compare
This was referenced Sep 23, 2026
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 #431
Fixes #432
Fixes #433
Fixes #443
feature/pdfa-2-conformancewas squash-merged intogravitypdfby #330 (f9d3db7, 23 Sep). Its contents are identical to the branch at 656219b. Four PRs were then merged into that branch, so their changes never reachedgravitypdf. This PR cherry-picks them, in the order they were merged, and adds one fix that the four needed together.Conflicts with
gravitypdfBoth were with #438 (#147), which gives an unnamed button a generated name, and which reached
gravitypdfafter the feature branch was merged.SetJSButton()kept Give a button with no name a name of its own #438'sunnamedButtonName('Button')fallback and took Shrink a form field's text to fit its field instead of cutting it off (#433) #441's move ofSetFormButton()below the icon registration.Set*()call in theprint_ob_*methods kept Give a button with no name a name of its own #438'sisset($objattr['fieldname'])guard and took Give an active form field the width and style of its CSS border (#431) #445's new$this->activeBorder($objattr)argument.#442 and #447 applied cleanly. After #446 merged, the branch was rebased onto it. The only conflict was the
form-fields-staticfixture, which #446 and #441/#442 both change; it was regenerated at each commit. It now shows #446's list boxes, the "Max length" value shrunk to fit (#441) and the "Styled" field in its CSS colour, background and border (#442), and nothing else moved. Apart from #438's lines,src/Form.phpafter the four picks is identical tofeature/pdfa-2-conformance.The fix in 736154f
feature/pdfa-2-conformancehas been broken since #447 merged:AnnotationObjectNumbersTest(4 errors),FormFieldShrinkTest::testIconButtonKeepsTheFieldsSize,SharedButtonNameTest::testImageButtonsThatShareANameKeepTheirIconsand theform-fields-activeandform-fields-pdfasnapshots all fail there. #447 merged three minutes after #469, and each PR's CI ran without the other.SetJSButton()'sSetFormButton()call below the icon registration, so that the field would know it shows an icon.$this->formCount. That is the button's number only afterSetFormButton()has counted the button.CrossReferenceWriter).The icon is now kept under
$this->formCount + 1, the numberSetFormButton()is about to give the button, which is the same idea as #438'sunnamedButtonName().SetFormButton()looks for it under$this->formCount. The failing tests listed above cover it; no new test was needed.Verification
composer test: 3879 tests, 5 skipped (these were skipped before this change too), no failures.composer test -- --group=snapshot: 90 OK.composer test -- --group=conformance(veraPDF): 29 OK.composer csis clean. PHPStan 2.2 reports no errors.php -lunder PHP 5.6 is clean.After this merges
gravitypdfand rebase them.feature/pdfa-2-conformance, so that nothing else is merged into it.🤖 Generated with Claude Code