[Bug]: Hybrid XFA (LiveCycle) forms show stale data in Acrobat after filling them in Stirling PDF
Description
Many public-administration and corporate forms are hybrid Adobe LiveCycle PDFs: they carry AcroForm fields and, in /AcroForm/XFA, an XFA packet describing the same form. Adobe Acrobat and Reader render the XFA; every other viewer (Stirling's own viewer, browsers, PDFium, pdf.js) renders the AcroForm fields.
Stirling PDF only writes the AcroForm half: the viewer's form bar and /api/v1/form/fill update /V and /AP, and the XFA datasets packet keeps the old values. The saved file then shows the user's data everywhere except in Acrobat, which shows the form as it was before.
These forms are also usually Reader extended (/Perms/UR3). Any full save invalidates that signature, so Reader opens the result with "This document enabled extended features in Adobe Acrobat Reader. The document has been changed since it was created and use of extended features is no longer available."
Steps to reproduce
- Take a static LiveCycle form (AcroForm fields plus an XFA packet), for example one of the Generalitat Valenciana's application forms.
- Fill a field in Stirling PDF, from the viewer's form bar or the Form Editor, and save.
- Open the result in Adobe Acrobat: the field shows its old (usually empty) value, and Reader warns about extended features.
Proposal
When Stirling saves a form it edited, keep both halves telling the same story:
- sync (default): write the AcroForm values into the XFA
datasets, resolving each field through the XFA template (global,onceandnonebindings, dotted subform names LiveCycle splits across AcroForm levels, check-button<items>, exclusion groups, rich text). - strip: remove the XFA, so every viewer uses the AcroForm fields (the LiveCycle scripts are lost).
- none: today's behaviour.
- sync and strip also remove
/Perms/UR3, which the save has already invalidated. - Dynamic XFA forms, which have no AcroForm fields, are refused with a clear message: only Acrobat can fill them.
- A standalone
POST /api/v1/form/xfa-syncrepairs a PDF that is already out of step and reports each field's XFA value before and after. - The editor tells the user when a PDF is a hybrid XFA form and lets them choose the mode.
PDFs without XFA are not touched. I have an implementation and will open a PR that references this issue.
Source: Stirling-Tools/Stirling-PDF