Repository navigation
Give every active form widget its own appearance, and ask the viewer to redraw only text it cannot shape (#348, #59) - #387
Merged
jakejackson1 merged 6 commits intoSep 23, 2026
Conversation
Member
Author
|
Support this when not PDF/A too. |
…he viewer to (#348) Checkboxes and radio buttons switched to ZapfDingbats, which mPDF cannot embed, so PDF/A and PDF/X threw. They now draw the shapes mPDF already has for formUseZapD = false, in the colour space the output intent allows. Under PDF/A, text fields, choices and push buttons get an appearance stream laid out when the widget is placed (value, password mask, wrapped textarea, selected option, list box highlight, caption or icon), the AcroForm drops /NeedAppearances, hidden inputs and noprint buttons are printed, and JavaScript, submit and reset actions are left out. Without PDFAauto the dropped actions and noprint are reported as PDF/A warnings. Other documents still ask the viewer to redraw widgets, and now name the ZaDb font it redraws checkboxes with in /DR, which stops poppler warning of an unknown font tag (#59). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Viewers that ignore /NeedAppearances, as many mobile, print and preview ones do, drew these widgets empty. The appearances PDF/A needed are now written for every document, with core-font text in Windows-1252 and embedded-font text in UTF-16. Outside PDF/A the form still asks the viewer to redraw them, and keeps its actions and its hidden and noprint flags. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…cannot shape Every widget now carries an appearance, so /NeedAppearances is written only when a field's value, options or caption is in a right-to-left script or a script with a shaper of its own (Otl::hasComplexScript), which mPDF's appearances neither reorder nor shape (#408). PDF/A never writes it. /ZaDb joins /DR only alongside the flag, when there is a checkbox or radio button to redraw (#59). Without the flag, viewers draw checkboxes and radio buttons from their own appearances, and the ZapfDingbats ones have no bounding box and no off state to draw. Every document now uses the vector shapes PDF/A and PDF/X already drew, and the formUseZapD property that chose between them is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ghostscript draws a widget from its appearance where it has one. In page-break-avoid-forms the select shows its selected option rather than its export value, the buttons show their captions, and the checkboxes and radio buttons are the vector shapes; in page-break-avoid-references only the text field is drawn differently. Neither document asks the viewer to redraw its widgets any more, so /NeedAppearances and /ZaDb are gone from both. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/348-pdfa-active-forms
branch
from
September 23, 2026 05:08
55735e8 to
055a94e
Compare
This was referenced Sep 23, 2026
…heckout writes no CR The paths were string literals running over two lines. With text=auto, Git checks them out with CRLF on Windows, and the carriage return reached the appearance stream, so the page-break-avoid-forms snapshot differed there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… PDF/A The same page of fields renders three ways: into the page without active forms (form-fields-static), as widgets with their own appearances (form-fields-active) and as a PDF/A-2b document drawn from the appearances alone (form-fields-pdfa). The page has text, password, read-only, disabled, required and maxlength inputs, short and wrapped text areas, a combo box, a list box and a multiple select, checkboxes and a radio group, submit, reset, script and image buttons, a hidden input, a field styled in CSS, and an Arabic value, which has the active document ask the viewer to redraw its widgets. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 23, 2026
jakejackson1
added a commit
that referenced
this pull request
Sep 23, 2026
…to redraw only text it cannot shape (#348, #59) (#387) * Draw every active form widget in a PDF/A document instead of asking the viewer to (#348) Checkboxes and radio buttons switched to ZapfDingbats, which mPDF cannot embed, so PDF/A and PDF/X threw. They now draw the shapes mPDF already has for formUseZapD = false, in the colour space the output intent allows. Under PDF/A, text fields, choices and push buttons get an appearance stream laid out when the widget is placed (value, password mask, wrapped textarea, selected option, list box highlight, caption or icon), the AcroForm drops /NeedAppearances, hidden inputs and noprint buttons are printed, and JavaScript, submit and reset actions are left out. Without PDFAauto the dropped actions and noprint are reported as PDF/A warnings. Other documents still ask the viewer to redraw widgets, and now name the ZaDb font it redraws checkboxes with in /DR, which stops poppler warning of an unknown font tag (#59). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Give every active text field, choice and push button its own appearance Viewers that ignore /NeedAppearances, as many mobile, print and preview ones do, drew these widgets empty. The appearances PDF/A needed are now written for every document, with core-font text in Windows-1252 and embedded-font text in UTF-16. Outside PDF/A the form still asks the viewer to redraw them, and keeps its actions and its hidden and noprint flags. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Ask the viewer to redraw form fields only for text their appearances cannot shape Every widget now carries an appearance, so /NeedAppearances is written only when a field's value, options or caption is in a right-to-left script or a script with a shaper of its own (Otl::hasComplexScript), which mPDF's appearances neither reorder nor shape (#408). PDF/A never writes it. /ZaDb joins /DR only alongside the flag, when there is a checkbox or radio button to redraw (#59). Without the flag, viewers draw checkboxes and radio buttons from their own appearances, and the ZapfDingbats ones have no bounding box and no off state to draw. Every document now uses the vector shapes PDF/A and PDF/X already drew, and the formUseZapD property that chose between them is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Refresh the form snapshots for the appearances every widget now carries Ghostscript draws a widget from its appearance where it has one. In page-break-avoid-forms the select shows its selected option rather than its export value, the buttons show their captions, and the checkboxes and radio buttons are the vector shapes; in page-break-avoid-references only the text field is drawn differently. Neither document asks the viewer to redraw its widgets any more, so /NeedAppearances and /ZaDb are gone from both. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Keep the check box and radio paths on one source line, so a Windows checkout writes no CR The paths were string literals running over two lines. With text=auto, Git checks them out with CRLF on Windows, and the carriage return reached the appearance stream, so the page-break-avoid-forms snapshot differed there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Snapshot every form field, drawn statically, as active widgets and in PDF/A The same page of fields renders three ways: into the page without active forms (form-fields-static), as widgets with their own appearances (form-fields-active) and as a PDF/A-2b document drawn from the appearances alone (form-fields-pdfa). The page has text, password, read-only, disabled, required and maxlength inputs, short and wrapped text areas, a combo box, a list box and a multiple select, checkboxes and a radio group, submit, reset, script and image buttons, a hidden input, a field styled in CSS, and an Arabic value, which has the active document ask the viewer to redraw its widgets. 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
…to redraw only text it cannot shape (#348, #59) (#387) * Draw every active form widget in a PDF/A document instead of asking the viewer to (#348) Checkboxes and radio buttons switched to ZapfDingbats, which mPDF cannot embed, so PDF/A and PDF/X threw. They now draw the shapes mPDF already has for formUseZapD = false, in the colour space the output intent allows. Under PDF/A, text fields, choices and push buttons get an appearance stream laid out when the widget is placed (value, password mask, wrapped textarea, selected option, list box highlight, caption or icon), the AcroForm drops /NeedAppearances, hidden inputs and noprint buttons are printed, and JavaScript, submit and reset actions are left out. Without PDFAauto the dropped actions and noprint are reported as PDF/A warnings. Other documents still ask the viewer to redraw widgets, and now name the ZaDb font it redraws checkboxes with in /DR, which stops poppler warning of an unknown font tag (#59). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Give every active text field, choice and push button its own appearance Viewers that ignore /NeedAppearances, as many mobile, print and preview ones do, drew these widgets empty. The appearances PDF/A needed are now written for every document, with core-font text in Windows-1252 and embedded-font text in UTF-16. Outside PDF/A the form still asks the viewer to redraw them, and keeps its actions and its hidden and noprint flags. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Ask the viewer to redraw form fields only for text their appearances cannot shape Every widget now carries an appearance, so /NeedAppearances is written only when a field's value, options or caption is in a right-to-left script or a script with a shaper of its own (Otl::hasComplexScript), which mPDF's appearances neither reorder nor shape (#408). PDF/A never writes it. /ZaDb joins /DR only alongside the flag, when there is a checkbox or radio button to redraw (#59). Without the flag, viewers draw checkboxes and radio buttons from their own appearances, and the ZapfDingbats ones have no bounding box and no off state to draw. Every document now uses the vector shapes PDF/A and PDF/X already drew, and the formUseZapD property that chose between them is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Refresh the form snapshots for the appearances every widget now carries Ghostscript draws a widget from its appearance where it has one. In page-break-avoid-forms the select shows its selected option rather than its export value, the buttons show their captions, and the checkboxes and radio buttons are the vector shapes; in page-break-avoid-references only the text field is drawn differently. Neither document asks the viewer to redraw its widgets any more, so /NeedAppearances and /ZaDb are gone from both. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Keep the check box and radio paths on one source line, so a Windows checkout writes no CR The paths were string literals running over two lines. With text=auto, Git checks them out with CRLF on Windows, and the carriage return reached the appearance stream, so the page-break-avoid-forms snapshot differed there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Snapshot every form field, drawn statically, as active widgets and in PDF/A The same page of fields renders three ways: into the page without active forms (form-fields-static), as widgets with their own appearances (form-fields-active) and as a PDF/A-2b document drawn from the appearances alone (form-fields-pdfa). The page has text, password, read-only, disabled, required and maxlength inputs, short and wrapped text areas, a combo box, a list box and a multiple select, checkboxes and a radio group, submit, reset, script and image buttons, a hidden input, a field styled in CSS, and an Arabic value, which has the active document ask the viewer to redraw its widgets. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 23, 2026
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 #348
Fixes #59
Active form widgets now come with their own appearances. PDF/A documents rely on those alone. Ordinary documents ask the viewer to redraw widgets only when a field's text needs shaping that mPDF cannot do yet.
What changed
Appearances for every active form. Every text field, textarea, password, list box, combo box and push button now gets an
/APstream, in every document. The layout is worked out when the widget is placed, because the field's font can only be measured then.*for a password, a word-wrapped textarea, and the selected option. A list box highlights the selection and scrolls to it./N << /Push … >> /AS /Push, which PDF/A requires of a Btn widget. Outside PDF/A they keep their actions alongside it.noprintbuttons get appearances too. Their/F 2and/F 0flags are unchanged outside PDF/A./NeedAppearances(many mobile, print and preview ones) previously drew these fields empty.Checkboxes and radio buttons are vector shapes everywhere. Every document now uses the shapes that PDF/A and PDF/X already drew, as proper form XObjects with a
/BBoxand both an on and an off stream. The ZapfDingbats appearances they replace had no bounding box, used the bare name/Offfor an unchecked box, and a glyph for an unselected radio. They were only usable because the viewer was always asked to redraw them. The ZapfDingbats path could not be embedded under PDF/A or PDF/X, and that is what made checkboxes throw (#348).Form::$formUseZapDis removed. It was a public property, reachable as$mpdf->form->formUseZapDbut not a config key, and it no longer selects anything./NeedAppearancesonly for text the appearances can't shape. mPDF's appearance text is neither shaped nor reordered (#408). So/NeedAppearances trueis written only when a field's value, options or caption:$mpdf->pregRTLcharstest), orOtl::hasComplexScript()checks this by reusingScriptRuns::split()andOtl::selectShaper(), the same pair OTL uses to choose a shaper.A Latin, Greek or Cyrillic form no longer carries the flag. Once #408 shapes the appearances, the flag can go; the code comment points there. Under PDF/A the flag is never written, so a PDF/A field in such a script shows its unshaped appearance until #408 is done.
#59.
/DRnames/ZaDb << /Type /Font /Subtype /Type1 /BaseFont /ZapfDingbats >>only when the flag is written and the form has a checkbox or radio button. That is the font viewers redraw them in. PDF/A never asks for a redraw, and PDF/X cannot name an unembedded font, so neither gets it. Without the flag, poppler draws the widgets from their appearances and has nothing to warn about. With it, the font is there to find.What PDF/A forbids, only under PDF/A:
/CO, which follows from dropping the JavaScript.noprintbuttons are written with the print flag.PDFAauto, the dropped actions andnoprintare recorded as PDF/A warnings, soOutput()throws.Mpdf::pdfaxWarning()is now public so thatFormcan share that gate.A checkbox or radio button now names its own field font in
/DA, rather than whichever font was current at output time.Snapshots
Each is refreshed in its own commit, after checking the rasterised pages:
page-break-avoid-forms/NeedAppearancesand/ZaDbare gone.page-break-avoid-references: only its text field is drawn differently, from its own appearance instead of Ghostscript's (RMSE about 0.012).New fixtures, all rendering the same page of fields (
tests/Snapshots/FormFields.php):form-fields-static:useActiveFormsoff, so each field is drawn into the page.form-fields-active:useActiveFormson, so every field is a widget with its own appearance. The Arabic value makes this the fixture that carries/NeedAppearances trueand/ZaDb.form-fields-pdfa: active forms under PDF/A-2b withPDFAauto, drawn from appearances alone, without the button actions and without/NeedAppearances.The page has:
maxlengthinputs;size="3"list box and amultipleselect with two selections;All three come out byte-identical run to run. They contain no carriage returns, no local or temp paths, and only DejaVu fonts from
font-bundle-lite. The image button's JPEG is embedded as is, not through GD. These fixtures will change when #330 picks up #419 (combo-box flag), #429 (disabled grey), #425 and #426.Verification
--group=conformance):testActiveFormConformspasses 1-B, 2-B, 2-U, 3-B and 3-U, each with an sRGB and a CMYK output intent. It includes text, password, hidden, textarea, checkbox, radio, combo, list, submit, reset and a JSnoprintbutton. The whole group passes (26 tests).FormAppearanceTest:/APand keep their actions and flags, in core-font and embedded-font mode./NeedAppearances./NeedAppearancesand/ZaDb. A Thai caption writes the flag only.pdftotextprints nothing, with or without the flag./APand/F 4, with no/AAand no/NeedAppearances.PDFAautowarns about actions andnoprint.OtlTest:hasComplexScript()for Latin, Greek and Cyrillic (false), and Devanagari, Arabic, Thai and mixed text (true). The form tests use Arabic, Hebrew and Thai because the bundled Devanagari font (FreeSerif) has SMP glyphs, which active forms refuse.AnnotationObjectNumbersTest: new cases for an ordinary embedded-font form and a PDF/A form check that every/APreference points at its appearance stream.pdftoppmand Ghostscript. Values, masks, wrapped text, selections, captions, ticks and dots all show.composer testpasses (3410 tests, the same 5 skips as the base branch).--group=snapshotpasses (88).composer csis clean. PHPStan 2 is clean; the$radio_colorand$radio_background_colorbaseline counts drop to 1.php -lunder PHP 5.6 is clean.feature/pdfa-2-conformanceafter Paint SVG gradient stops opaque under PDF/A-1b, and write only the visibility groups the catalog lists (#346, #351) #386.Limits
Tag\Selectsetssizeonly when it is above 1, so an HTML<select>never gets the combo-box flag and is always written as a list box.🤖 Generated with Claude Code