pdfcraft/crates/forms/src
ysrdevs 82b709d516
XFA: import and export data files, and pictures for image fields (#1175)
Export Data on an XFA form writes its data as Acrobat does: XML (the
data alone, rooted at the form's root data node, its namespaces
declared) or an XDP holding the whole datasets and a reference to the
PDF (.xdp, a new format). Import Data takes an XDP, a datasets or data element, or a
data document whose root is the form's root data node, and makes it
the form's whole data, keeping data descriptions; a laid-out form is
laid out again from it (rows added and removed) and its calculations
run; XFDF, FDF and tables still go the AcroForm way. Undoable.

Image fields are now buttons marked /PCXfaImage (no PDF action): the
forms layer treats one as an image field, so clicking it (or
form_set_image) picks a picture, which is kept in the data as base64
with its xfa:contentType, as Designer saves it, and the laid-out form
shows it from there.

xfa: replace_data, write_data_image (hostile content types cleaned,
32 MB cap), export_data, import_data (64 MB cap, the parser's node
limit, self-closing data elements). engine: export routing by
document kind, import routing by the file's root element, re-layout
and calculation after the data changes outside the fields, the
picture's content type from its bytes. UI: XML and XDP in the export
dialog of an XFA form, .xdp in the import filter. Tool texts, README
and parity (form.xfa-data) updated.

Hardened after an adversarial review pass: the file's data is held as
a tree and written with the packet's own namespace prefix (never its
markup), every packet rewrite is parsed back before it is written,
files capped at 16 MB and 64 levels (a tag scan before the recursive
parser, also guarding the datasets parser), pictures at 8 MB and PNG/
JPEG/GIF only, the file's shape and root name checked, UTF-16 and
ISO-8859-1 decoded, pictures into data groups refused, cleaned names
for pictures, static forms empty the fields the file doesn't hold,
more rows than the layout cap reported, one datasets stream per edit,
and only image fields take pictures into the data.
2026-10-11 18:29:35 -04:00
..
actions.rs Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
af.rs Run set-layer-visibility actions from links and push buttons (#292) 2026-10-08 11:27:10 -04:00
appearance.rs M14: text the fonts can't draw is kept and reported, never written as ? silently (#1112) 2026-10-11 17:53:55 -04:00
author.rs M14: text the fonts can't draw is kept and reported, never written as ? silently (#1112) 2026-10-11 17:53:55 -04:00
detect.rs Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
lib.rs XFA: import and export data files, and pictures for image fields (#1175) 2026-10-11 18:29:35 -04:00
scripting.rs Forms: keep tiles and render unbaked field values during page re-render (#636) 2026-10-11 15:15:48 -04:00
tests.rs M14: text the fonts can't draw is kept and reported, never written as ? silently (#1112) 2026-10-11 17:53:55 -04:00