Automatic XFA native graphics and images

Unit: HPDFXFAHeadless

HPDFXFAWriteHeadlessPDF consumes rectangle, line, arc and inline image draw callbacks directly from XDP, alongside the existing text and widget consumers

Each draw produces a native Form XObject placed on the actual layout page; image draws contain real Image XObjects and alpha soft masks when needed

Vector paths

Rectangles use native PDF rectangle paths, lines preserve slash or backslash slope, and elliptical arcs use cubic segments of at most 90 degrees

The first effective edge supplies RGB stroke colour and thickness, including subpoint widths; stroke appearance bounds include half the thickness so the form does not clip its own border

Arcs consume startAngle and signed sweepAngle, with a default full revolution and a maximum absolute sweep of 360 degrees

Draw rotation, scale and translation hints are applied once in a finite affine placement around the draw centre, with counterclockwise positive rotation; top-left XFA coordinates are converted once to the native PDF origin

PNG and JPEG

FormatActual native consumption
PNG grayscale1, 2, 4, 8 and 16-bit samples, with packed samples expanded to 8 bits and 16-bit precision retained
PNG RGB8 and 16-bit colour samples
PNG indexed colour1, 2, 4 and 8-bit indices expanded through the palette into RGB samples
PNG transparencyGrayscale and RGB transparent samples, palette alpha, and 8 or 16-bit grayscale-alpha and RGBA; actual /SMask streams preserve alpha precision
PNG filtering and interlaceAll five PNG row filters and Adam7 passes, validated through the shared native zlib and predictor implementations
JPEG8-bit baseline and progressive grayscale, RGB and CMYK frames, validated with the shared native JPEG decoder before preserving the original /DCTDecode stream

PNG chunk checksums, ordering, dimensions, palette indices, transparent sample ranges and exact decompressed length are checked before committing a candidate; truncated or excess compressed data fails preparation

JPEG frame dimensions must agree with real native decoding, and Adobe CMYK inversion is declared explicitly in the image dictionary

JPEG requires the existing native TurboJPEG runtime; HOTPDF_TURBOJPEG_LIBRARY can identify an absolute library path, with dependent libraries discoverable by the operating system

Image aspect supports fit, none, width, height and actual; PNG pHYs and JPEG JFIF density determine physical pixel size, with 96 dpi used when no usable density exists

Scaled images are centred and clipped to the XFA draw rectangle; alpha composition remains a native PDF reader operation

Bounds and transaction

Encoded image bytes, decoded working buffers and raw image or alpha streams are bounded before allocation; native object limits and aggregate image and font stream limits remain active

Cancellation is checked whilst parsing chunks, inflating data, decoding rows and placing native objects; the existing native JPEG decoder receives the caller token

Preparation failures preserve destination position, length and bytes; the final destination WriteBuffer follows the caller stream's own I/O semantics

Current boundaries

Filled shapes, corner styling, edge-specific borders, dash patterns, barcodes, external image transport, imageEdit widgets, alternate image formats, embedded color profiles and Exif orientation still require additional consumer integration

Animated PNG is consumed as its default static image; foreign XML exData remains a separate feature, and this draw adapter does not execute arbitrary embedded objects

Acceptance

Tests/Linux/Build-XFAHeadlessGraphicFixtures.py produces deterministic row-filter, Adam7, sample-precision, transparency, physical-aspect, JPEG and malformed protocol fixtures

Tests/Linux/XFAHeadlessGraphicsTests.pas writes and reopens actual native PDFs and verifies caller preservation on failures; Verify-XFAHeadlessGraphics.py independently checks decoded image samples, /SMask precision, vector operators, placement and rendered pixels with pypdf and MuPDF

Automatic XFA native PDF creation describes the existing field and text consumers and the public options and result APIs