Skip to content

Make an inline form font an object of its own before an appearance names it - #134

Open
bobsingor wants to merge 2 commits into
embedpdf/mainfrom
embedpdf/fix/inline-dr-font
Open

bobsingor wants to merge 2 commits into
embedpdf/mainfrom
embedpdf/fix/inline-dr-font

Conversation

@bobsingor

Copy link
Copy Markdown
Contributor

Cause

Filled fields blank in Acrobat. When a form's font is written inline in /AcroForm /DR (a dictionary inside /DR, not an object of its own), CPDF_AnnotFontMap::PrepareFontResources gives the appearance a fill writes an inline copy of it (font_dict->Clone()). Acrobat 26 then shows none of the editable text fields filled that way: nothing is drawn, the field has no highlight, and it can't be clicked. Read-only fields still show.

Acrobat was checked one change at a time, starting from the engine's filled file:

  • the fonts in the appearances made objects of their own, /DR still inline: still blank;
  • the /DR font made an object of its own, the appearances keeping their inline copies: every field shows, live;
  • both naming one object: every field shows, live.

So Acrobat minds the font that /DR holds inline. Real forms keep their /DR fonts as objects of their own (none of 131 real-world forms in a local scan writes them inline); hand-written and generated files often don't.

A stray appearance on a created field. CollectRawTxnControls takes a field without /Kids to be its own widget even when it is not a widget annotation. The engine creates a field, sets its flags, then attaches its widgets, so making a new field read-only (EPDFForm_SetFieldFlags, then RegenerateFieldAppearances) drew an appearance with /BBox [0 0 0 0] onto the field dictionary itself, beside its widget's real one. A value written and redrawn before the widget is attached did the same.

Change

  • ResolveDaFontForPersistentTarget makes a /DR font that is written inline an object of its own (MakeInlineDrFontAnObject, written through the document's writable catalog chain, as the fallback beside it is) before an appearance written into the file names it. /DR and the appearance then name the same object. Form fields, free text and redaction overlays all resolve their font there; ephemeral appearances are unchanged. A font that already is an object is used as it is, and /DR is not written.
  • A field without /Kids is its own widget only with /Subtype /Widget, as CPDF_InteractiveForm::AddTerminalField reads it. A field with no widget yet has no controls: its value is written, and nothing is drawn.
  • The ledger's own-appearance-generator rule names the new helper and its tests.

Tests

  • EPDFFormEmbedderTest.AFillMakesAnInlineFormFontAnObject: two fills of a form whose /DR font is inline. /DR and both appearances name one new object, in memory and in the saved file.
  • AnInlineFormFontBecomesAnObjectInATransaction: the same in a layer transaction, as the engine writes.
  • AFormFontThatIsAnObjectIsNamedAsItIs: text_form.pdf's font is named as it is, and /DR is not written (nothing of it is promoted on a layer).
  • AFieldWithoutWidgetsGetsNoDrawing: create a field, make it read-only, fill it, then attach a widget. The field dictionary never gets an /AP; the widget does.
  • AFillMakesAnInlineFormFontAnObject and AFieldWithoutWidgetsGetsNoDrawing are listed as layer-mode writers.

Checked

Checked on the branch head (both commits together).

  • Without the change the first, second and fourth tests fail; the third passes either way.
  • macOS: unit 1412 passed. Embedder 1888 passed and the 12 golden failures of the base; the suite without those 12 exits 0, and the saved-PDF checker reads its 49 saved PDFs without recovery.
  • The whole suite in layer mode, macOS and Linux: no error. On macOS the counts are the base's apart from the new tests, and every existing test leaves the same number of objects in its layer.
  • Pixel runner (macOS): the same as the base, 147 passed, 26 suppressed, 2 surprises and 51 failures, the same files.
  • Linux x64 in the release image: unit 1419 passed, embedder 1902 passed, none failed.
  • check-fork-tags.py --strict, check-c-api.py (604 functions), check-globals.py on the macOS library.
  • Built into the engine (WebAssembly and macOS): new conformance cases for both changes fail on the released library and pass with this one, on the local and the cloud engine; the whole local (2154) and cloud (1295) engine suites pass.
  • Acrobat 26.002: the filled file that showed four blank fields shows all four with their text, live, and takes the cursor. A form signed while its /DR font was inline, then filled (so this change makes the font an object after the signature): with an approval signature Acrobat says the signed revision is unaltered and lists "Form Fields Filled In"; with a certification at P=2 it says the changes are permitted by the certifying party, with the same list. The engine's signature analysis says permitted for both.

Left

  • Release, and the pin in embed-pdf-viewer, with the engine conformance suite for both changes.
  • check-globals.py on the Linux library: not run.
  • Not part of this change: upstream's form filler (CPDF_BAFontMap) copies an inline font into the appearances it writes the same way. The engine does not write through it.

…mes it

When a form's font is written inline in /AcroForm /DR (a dictionary inside
/DR, not an object of its own), the appearance a fill writes got an inline
copy of it, and Acrobat showed none of the editable fields filled that way:
nothing drawn, no highlight, no click. Acrobat minds the font /DR holds
inline; the appearance's own copy alone does not matter.

The first appearance written into the file that names such a font now makes
it an object of its own, which /DR and the appearance both name.
A field without /Kids was taken to be its own widget even when it is not a
widget annotation. The engine creates a field, sets its flags, then attaches
its widgets, so making a new field read-only drew an appearance with an empty
box onto the field dictionary itself. Such a field is its own widget only
with /Subtype /Widget, as CPDF_InteractiveForm reads it.
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