Automatic XFA native PDF creation

Unit: HPDFXFAHeadless

HPDFXFAWriteHeadlessPDF creates a fresh native PDF directly from XDP bytes and an application-supplied TrueType font, without an input PDF or prepared field slots

The adapter consumes the existing XFA binding, repeated-instance and pagination layout callbacks and builds native page and AcroForm object graphs with real embedded-font appearance streams

Text, numeric, date and password fields, push buttons, combo and list choices, checkbox and radio groups, static text, rectangle, line, arc and inline PNG or JPEG image draws are consumed; signatures and additional draw consumers require further adapter integration

Choice and boolean creation preserves separate display and export values, editable and multi-select behavior, native appearance states and independent repeated radio groups

Boolean styles and captions consumes actual vector markers, size, outline colors and thickness, Unicode caption regions and third checkbox states

Native graphics and images consumes actual vector paths, PNG sample formats and transparency, baseline or progressive JPEG, physical aspect and affine placement

Passwords use a masked appearance while retaining the native field value; document-wide Editable and effective XFA readOnly access determine native field flags

XFA point coordinates use a top-left origin and are converted once into native widget rectangles and draw translations; separate repeated occurrences receive distinct native field names from the layout engine

Native /AP, /DR and /DA resources are generated with the supplied font and effective size, color and alignment; the supplied face is used for every field, so typeface selection and multiple style faces are application responsibilities in this stage

Use TXFAWidgetRuntime to execute lifecycle or interaction events and save the resulting XDP before creation when the document requires those events; the adapter's ScriptOptions control the flatten engine's calculate and validate processing

Preparation and limits

TXFAHeadlessPDFOptions bounds XDP and font bytes, output and object bytes, object and page counts, fields and aggregate UTF-16 glyph units

Object, page and glyph budgets are checked before their corresponding allocations; embedding checks bound aggregate font and image streams, image decoders bound their working buffers, and native serialization enforces object and complete candidate byte limits

Cancellation is checked throughout graph creation, appearance generation and serialization; all preparation failures leave the destination stream's position, length and existing bytes unchanged

The complete candidate is prepared in memory before one WriteBuffer call to the destination; destination I/O errors propagate and may leave partial writes according to the caller's stream behavior

The output is a new unsigned document; preserving imported encryption, existing signatures and source revisions belongs to the native document import and revision APIs

Acceptance

Tests/Linux/XFAHeadlessCreationTests.pas produces actual repeated, paginated and globally read-only documents, an event-mutated saved-XDP document and a styled Unicode draw document without opening a reader UI

Tests/Linux/Verify-XFAHeadlessCreation.py independently verifies native values, field flags, page ownership, /AP and embedded font resources with pypdf, and real text and rendered appearance pixels with MuPDF

Tests/Linux/XFAHeadlessChoiceTests.pas and Verify-XFAHeadlessChoice.py add actual choice values and flags, radio parents and repeated scope identities, reserved export states, runtime save/reload and rollback, and rendered selection pixels

TXFAHeadlessPDFResult reports the actual native graph and serialization counts