Native page imports and preserved PDF/A-4

Append selected pages with their original text and vector content streams, inherited MediaBox/CropBox/Rotate, explicit UserUnit, embedded fonts, images, shared resources and cyclic indirect identities. Native rendering and import continue looking up inherited boxes and rotation when a page entry is omitted or resolves to null

When an imported page retains an explicit non-null UserUnit, HotPDF raises an older destination's effective PDF version to 1.6 in its catalog and preserves the original file header

Copied page and Form transparency groups, including flattened annotation appearances, require an effective PDF version of at least 1.4. HotPDF declares it in the destination catalog when necessary

The same PDF 1.4 requirement applies to non-null transparency parameters in copied graphics-state resources, such as alpha constants and blend modes, as well as to image soft masks. Shading pattern graphics states are checked for the same transparency parameters

Recovered annotation appearances also use transparency graphics states. When import generates one of these Forms, it declares PDF 1.4 in an older destination catalog while preserving the original file header

Copied streams that use JBIG2Decode or JPXDecode require PDF 1.4 or 1.5 respectively. Import keeps the encoded image data, resolves indirect filter names and arrays, and declares the required version in older destination catalogs

Image XObjects with 16 bits per component also require PDF 1.5. Import retains the original samples and raises the effective catalog version when necessary

Explicit and color-key image masks require PDF 1.3. When the destination header predates PDF 1.3, native import declares at least PDF 1.4 in the catalog so the version override and retained mask are both supported

Import resolves an indirect DecodeParms dictionary or array when copying its stream, preserves the encoded bytes, and remaps references inside the parameters to the destination

Embedded OpenType font programs retain their original stream data and require PDF 1.6. Native import declares the required version in older destination catalogs

Retained XMP metadata streams attached to imported pages or their resources require PDF 1.4. Import preserves the metadata and updates an older destination catalog when needed

Retained page presentation steps (PresSteps) require PDF 1.5. Ordinary import raises the effective catalog version when needed

Retained Fly, Push, Cover, Uncover, and Fade page transitions and the SS and B transition parameters also require PDF 1.5

Optional-content groups referenced by copied page resources are registered in the destination. The source default BaseState, ON and OFF settings determine the imported groups' initial states. Existing destination groups and default configuration entries remain in place, including the destination's Intent. A destination without a default configuration inherits the source default intent. Deleted or stale references in a page or Form's named Properties entries, a stream's optional-content entry, or a membership dictionary's group list or visibility expression are copied as null so their fallback behavior survives import

The source default layer-panel Order is appended to the destination panel in its original order, with labels and sublayers remapped to copied groups. Branches with no copied groups are dropped. When a parent is omitted, null, or a stale reference, copied children in its unlabeled branch move up one level

Imported layers retain source default Locked and RBGroups settings alongside existing destination settings. Mutually exclusive sets retain their copied members when at least two remain. If imported locks require PDF 1.6, the catalog raises the effective version

Copied optional-content membership dictionaries with a retained VE visibility expression also require PDF 1.6. The import raises the effective catalog version when needed

Source default AS usage applications retain their event and categories for the copied groups they target. Applications with no copied groups are omitted. A viewer can use the retained rules when adjusting layers for print, export, zoom or other usage categories

Native rendering treats null values for optional usage entries as omitted. For example, a null AS array does not adjust layer states, and a null upper zoom bound leaves the zoom range open

When an alternate configuration is selected after import, layers from its original document use the alternate configuration's AS rules. Layers from the other document keep the usage rules of their default configuration

The other document also keeps its default layer-panel order, radio groups, and locks when a preset is selected. An empty panel or radio-group array in a preset clears that setting for the preset's own document

HotPDF preserves the language tags of omitted layers for exact-match decisions in the same usage rule. These tags are stored in HotPDFLanguagePeers and do not add layers to the imported page. Other PDF processors may evaluate language matches using only the copied groups

Alternate layer configurations are retained. Source configurations remap state overrides, panel entries, locks, radio groups and usage rules to copied layers. Both source and destination alternatives use BaseState /Unchanged with explicit state arrays for the layers in their original document, so applying a preset leaves the other document's layer states alone. HotPDF rendering evaluates each document's groups using that document's default or selected Intent. The saved PDF retains the standard configuration intents and stores the per-origin intent scopes in HotPDFLayerIntents. Other PDF processors may apply only the standard document-wide intent. A preset that omits Order or RBGroups retains the values inherited from its own document's default configuration. An explicitly empty array clears the corresponding setting for that preset. If an imported preset has the same name as an existing configuration, it receives the first available numbered suffix, starting at (2)

AppendImportedPages operates on two distinct loaded documents, preserves the destination revision and encryption, and stages all imported objects before committing the page tree; duplicate selection, invalid references, cancellation, permissions and byte/object/page budgets leave the destination unchanged

Selected source annotations become ordinary Form XObject content using their normal appearance state, BBox and Matrix after normalizing reversed /Rect corners per ISO 32000-1 §7.9.5; source interactions and fields are not imported, pages with zero flattened annotations keep their original content streams unwrapped, and flattenAnnotations=false explicitly removes all source annotations

Flattening resolves normal appearance streams at their original object generation, including streams selected by an appearance state, and assigns them new destination references

Flattening adds appearance names only to the annotated page's XObject resource dictionary. Other pages and Forms retain their original resource names and can still share the underlying XObjects

A missing or null page Contents entry represents an empty page body. Native text extraction and rendering treat them alike, and import can still flatten the page's visible annotations

Native text extraction, rendering and annotation flattening skip null members of a Contents array and retain the order of its content streams

Flattened appearance transforms and synthesized FreeText geometry use PDF decimal notation, including subpixel offsets and small scale factors

Positive transformed appearance bounds below one millionth of a point can still be fitted to the annotation rectangle. When a placement exceeds the native content operand range, import splits it into a sequence of matrices with bounded operands

Native rendering uses the identity transform for omitted or null Matrix entries in patterns and Forms, including annotation appearances and soft masks

Generated appearance dictionaries write small numeric values, including stroke and fill opacity, as PDF decimals without rounding them to zero

Flattening preserves the source view for annotation visibility flags. Hidden and NoView annotations are removed. The Invisible flag suppresses unknown subtypes; standard annotations with that flag still use their normal appearance

Flattened annotations retain their layer membership through marked content, and their normal appearance Forms retain their own layer entries. An existing appearance or one generated through an enabled synthesis option can become visible in another preset even when the source default configuration hides it. With synthesis disabled for an annotation, a missing normal appearance on a default-hidden layer is omitted. This visibility check is limited to 500,000 operations across the import and shares the import working-memory limit

Visible annotations require usable normal appearances by default; the optional native appearance recovery and supplied-font FreeText profiles below extend that behavior, while signed or certified destination documents retain their existing separate policies

When flattening a normal annotation appearance with an omitted or null Subtype, import declares the copied stream as a Form XObject and retains its existing content and resources

Native vector flattening preserves an explicit NoRotate annotation's upright orientation and upper-left anchor on the source page, using its effective inherited or direct page rotation. The saved appearance is ordinary page content and follows subsequent page transformations

Text annotation icons stay upright in the source view even when the annotation omits the NoRotate flag. This applies to both existing normal appearances and appearances generated during import

Vector flattening preserves the size and anchor of NoZoom appearances at the source page's 100 percent view scale, including pages with a nondefault UserUnit and annotations that also set NoRotate. After flattening, the appearance scales with the rest of the page content

Source user passwords must grant text extraction, and destination user passwords must grant content modification; owner authentication bypasses these permission restrictions

Opt-in native vector appearance recovery

Version 2.1205.0 adds SynthesizeMissingAppearances to THPDFHeadlessPageImportOptions, default false, for annotation flattening with the same supported static geometry and text profiles as native annotation appearance recovery

Recovered appearances become persistent Form XObjects with cloned font and nested icon resources, not page-sized images; text remains available to extraction, and the destination can be saved and reopened after releasing the source document

Text fields, buttons, choices and geometric annotations use the source's appearance characteristics, including widget quarter-turn layout; original-font captions retain the source font program, while standard-font substitutions use the installed native font provider

Recovered text fields, combo boxes and list boxes paint explicit /MK /BC and /MK /BG colors as a vector border and background before drawing the text

When flattening a combo box with a missing appearance, native page import honors the field text alignment (/Q) for captions that fit

For rectangular widgets, an underline border style (/BS /S /U) strokes the bottom edge and paints the background independently of that stroke

Beveled and inset borders on rectangular widgets use lighter and darker vector bands derived from the border color, with the shading reversed for the inset style

Dashed borders on rectangular widgets and radio buttons leave the background visible between dashes and fill the widget through the outer edge

Generated appearances preserve the dash pattern in a legacy /Border array. A present /BS dictionary takes precedence

Generated polygon, polyline, and ink appearances use their vertex or ink-list geometry when /Path is omitted or null

With missing-appearance synthesis enabled, import flattens an unsigned signature widget into a static vector frame using the widget border, background and rotation

An existing normal appearance stream takes precedence. A missing or null normal entry, including a missing or null entry selected by a valid appearance state, uses the opt-in recovery. An explicitly enabled supplied-font SynthesizeMissingFreeText takes precedence for FreeText; unsupported text policies and malformed geometry retain concrete diagnostics rather than being approximated

Known annotations with no static mark, such as Popup attachments or an empty rectangle, are removed and counted in RemovedAnnotations; unknown annotation subtypes remain invalid synthesis input

SynthesizedAnnotations counts all newly generated persistent appearances, including the explicit supplied-font FreeText path; SynthesizedFreeTextAnnotations continues to count only that older explicit-font path, and both are subsets of FlattenedAnnotations

MaxSynthesisOperations defaults to 500000 and bounds aggregate generation work across the import; retained generator resources and their destination copies share MaxWorkingBytes while both are alive, and source and destination cancellation tokens are combined

Options := THPDFHeadlessPageImportOptions.Default;
Options.SynthesizeMissingAppearances := True;
ImportResult := Destination.AppendImportedPages(Source, [0], Options);
Source.Free;
Destination.SaveToFile('combined.pdf');

The existing pages.import JSON operation accepts synthesizeMissingAppearances: true and an optional positive Int32 maxSynthesisOperations; it reports synthesizedAnnotations alongside the existing flattened, removed and explicit-FreeText counters

Capability discovery advertises pageImport.missingAppearanceSynthesis.profile = native-vector-v1; callback records, ABI version and binary record sizes are unchanged

Focused Linux FPC 3.3.1 checks cover ordinary and AES-256 source documents, mixed generated text and original CFF fonts, rotated icons, a no-mark Popup, byte-identical before/after pixels, searchable saved output, source release, the real C ABI consumer and a byte-atomic synthesis-work refusal

Opt-in persistent FreeText appearances

The Pascal AppendImportedPages API can synthesize a missing or null normal appearance for a visible FreeText annotation when SynthesizeMissingFreeText is explicitly enabled with annotation flattening

Supply MissingFreeTextFontResource, the exact case-sensitive decoded DA font name without its syntax slash, and choose either the individual font inputs or the named family array below. Font programs must allow editable or installable outline embedding

The finite profile supports a positive rectangle, Unicode contents with CR, LF or CRLF line breaks, one Tf font selection with a nonnegative size, DA text color in gray (g), RGB (rg), or CMYK (k) and left, center or right alignment through Q; comments and ordinary PDF whitespace in DA use the shared content tokenizer

Contents are read as a PDF text string, so a UTF-16BE byte-order mark yields Unicode scalars and its absence yields PDFDocEncoding; the supplied font decides coverage, and a scalar it cannot map is rejected with that scalar named in the diagnostic

The destination document's MaxGlyphs budget counts decoded Unicode scalars rather than UTF-16 code units after a conservative 2 * MaxGlyphs code-unit pre-check, matching the text-appearance generator so supplementary-plane characters encoded as UTF-16 surrogate pairs consume one glyph budget unit instead of two

Text uses actual supplied-font metrics and word wrapping with line spacing 1.2; padding is the smaller of two points and one quarter of the smaller rectangle dimension

The DA Tc and Tw operators set character and word spacing in points. Word spacing applies to ordinary spaces. Both values affect line measurement, wrapping, and alignment, and the last value for each operator takes effect

A zero Tf size fits all lines to the available width and height after padding and any /RD insets. A positive size is used as supplied

Solid square borders retain the default one-point width or an explicit nonnegative width, including a zero-width border; the border uses the DA text color, including the original CMYK components when selected, while C supplies an optional Gray, RGB or CMYK background

Borders may be solid, dashed, beveled, inset, or underlined. Beveled and inset borders use opposing vector bands shaded from the default appearance color and follow the inner rectangle when /RD is present. An underline (/BS /S /U) follows only the bottom edge, using the inner rectangle when /RD is present. A zero-width underline leaves only the background and text. The legacy Border array also supplies horizontal and vertical corner radii for a rounded background and stroke. The border style dictionary takes precedence over the legacy Border array, and a dashed border style without a dash array uses a three-point dash. The emitted border keeps the supplied pattern without changing the text appearance

A FreeText /RD array sets the left, top, right, and bottom insets for text layout, background, and border. The insets must be nonnegative and leave a nonempty inner rectangle. The original annotation rectangle still determines where the appearance is placed on the page

FreeText markup opacity (/CA) ranges from zero to one and applies to the completed appearance as a group. The destination Catalog declares PDF 1.4 when a generated transparency group requires it and the destination uses an older version

/FreeTextCallout uses the four or six /CL coordinates in page space for a straight or bent line. The /LE ending supports None, OpenArrow, ClosedArrow, ROpenArrow, RClosedArrow, Square, Circle, Diamond, Butt, and Slash. The label still uses the supplied font and the /RD inner rectangle

The FreeText /Rotate compatibility entry accepts signed multiples of 90 degrees and rotates the label counterclockwise within its text rectangle. The background, border, callout and annotation placement stay aligned to the page

The border effect dictionary (/BE) supports a cloudy outline with an intensity from zero to two. Positive intensity and border width generate a vector cloud for the background and border, and zero intensity keeps the ordinary contour. The cloud can extend into the outer annotation margin while the text remains inside the inset box

A nonempty /RC XHTML string or stream supplies the rich label. The optional /DS style string sets defaults for the XHTML or, when rich content is absent or empty, the plain contents. Supply optional MissingFreeTextBoldFont, MissingFreeTextItalicFont, and MissingFreeTextBoldItalicFont programs for styled runs. Every requested style requires its matching font program. Rich layout supports the existing paragraph, color, size, and text decoration properties, and converts inherited CMYK text color to RGB. Additional DA operators outside this profile produce a diagnostic

For text that requires complex layout, the supplied font is shaped with HarfBuzz and FriBidi for bidirectional ordering, cursive joining, and combining marks. This path requires both libraries to support the HotPDF workspace allocator ABI. Shaped appearances carry the original logical Unicode text for extraction. Control characters, noncharacters, and unpaired UTF-16 surrogates remain invalid for this import profile

Each generated normal appearance is an owned persistent Form with embedded font resources, a glyph map and ToUnicode; the destination can be saved, reloaded and saved again after the source document and caller font buffer have been released

Font and resource-name inputs are independently copied into the transaction, generated objects stay pending until all import checks succeed, and cancellation or admission failure publishes no partial page tree

SynthesizedFreeTextAnnotations counts generated appearances as a subset of FlattenedAnnotations; existing appearances are preserved through the normal clone path

Always initialize the managed options record with Default and rebuild Pascal clients for its extended layout and the result record's added counter

For rich labels, MissingFreeTextFontFamilies accepts one to sixteen named families as an alternative to the individual font inputs. The first family supplies the default and must include a regular face. Family names must be distinct under ASCII case folding. The existing rich appearance engine selects the requested CSS family and style, then tries declared fallback names and configured families for complete graphemes. Font lookup uses the supplied programs. A plain label without rich content or a default style uses the first regular face

JSON and C ABI opt-in

The existing pages.import JSON operation exposes the same supplied-font Unicode synthesis profile through the versioned Linux C ABI, without changing the C callback or operation records; capability discovery advertises it as supplied-font-unicode-v2

JSON memberContract
synthesizeMissingFreeTextBoolean, default false; enable explicitly with annotation flattening to generate a missing FreeText normal appearance within the profile above
missingFreeTextFontResourceExact case-sensitive decoded DA font name, such as F0; the supplied value is neither stripped of a syntax slash nor PDF-name-decoded again
missingFreeTextFontBase64Caller-supplied genuine font-program bytes encoded as strict padded Base64; the existing appearance provider validates font structure, glyphs and embedding permissions
missingFreeTextBoldFontBase64, missingFreeTextItalicFontBase64, missingFreeTextBoldItalicFontBase64Optional matching font programs encoded as strict padded Base64. All supplied faces share the decode byte budget and are used only when the corresponding style is selected
missingFreeTextFontFamiliesAlternative array of family objects with name and any of fontBase64, boldFontBase64, italicFontBase64, and boldItalicFontBase64. The first family requires fontBase64. All programs share the import font decode budget

Decoded font bytes are bounded by the smaller of the document's MaxDecodedBytes and one quarter of the operation's limits.memoryBytes; the complete operation JSON also remains within the existing 4 MiB input limit

When flattenAnnotations is false, source annotations are removed without synthesis, the font payload is not decoded and synthesizedFreeTextAnnotations is zero even if synthesis was requested

A successful JSON result includes synthesizedFreeTextAnnotations as the generated subset of flattenedAnnotations; existing normal appearances retain the clone path and do not increment the synthesis counter

Construct the request from a real font file rather than substituting example bytes for a valid program; pass that file path as the first argument to this Python request-construction code

import base64
import json
import sys
from pathlib import Path

font_bytes = Path(sys.argv[1]).read_bytes()
request = {
    "schemaVersion": 1,
    "type": "pages.import",
    "pages": [0],
    "flattenAnnotations": True,
    "synthesizeMissingFreeText": True,
    "missingFreeTextFontResource": "F0",
    "missingFreeTextFontBase64": base64.b64encode(font_bytes).decode("ascii"),
}
print(json.dumps(request))

The operation still requires a loaded destination handle and a separate source-PDF InputIO; font data and generated resources retain the existing ownership, bounded preparation and failed-publication recovery contracts

Platform and compiler acceptance remain tied to the actual source identities and recorded executions rather than implied by the API binding

Verified preservation

HPDFConvertHeadlessToPDFA4PreservingFile creates an independent PDF 2.0 document with actual sRGB output intent and PDF/A-4 XMP, imports original content and flattened appearances, validates the staged candidate with the genuine veraPDF CLI, and publishes only compliant output atomically

Preserving PDF/A-4 conversion gives unnamed or duplicate optional-content configurations unique names before validation and retains their layer visibility settings

When a layer configuration contains an Order array, preserving PDF/A-4 conversion appends any missing layers at the end. Existing panel hierarchy, order, and visibility settings are retained

Preserving PDF/A-4 conversion omits page presentation steps (PresSteps) and keeps the original page content

The conversion removes original encryption, interactive fields, signatures, catalog actions, document metadata and catalog attachments while preserving reachable page content/resources; allowSignatureInvalidation must be explicit when the source contains signed fields

The default path preserves original font programs; explicit font repair adds bounded normalization and embedding of available substitutes for missing fonts, and every final candidate still requires genuine PDF/A-4 validation before replacing the destination

Validator configuration

Install headless Java and the official veraPDF CLI JAR, then set HOTPDF_VERAPDF_JAR and HOTPDF_VERAPDF_JAVA or configure ValidatorJAR and JavaExecutable in Pascal; the default paths are /usr/bin/java and /opt/hotpdf-verapdf/cli.jar

Validation uses separate process arguments, headless Java, a configured heap limit, bounded stdout/stderr, a time budget and cancellation; timeout/cancellation terminates and reaps the child process and removes private staging files

The managed preparation and Java heap limits do not represent an operating-system RSS cap

Callback operations

{"schemaVersion":1,"type":"pages.import","pages":[2,0,1],"sourcePassword":"source-owner","flattenAnnotations":true}
{"schemaVersion":1,"type":"pdfa.convert","profile":"PDF/A-4","mode":"preserve"}

pages.import requires a loaded destination handle and a separate source InputIO; destination authentication stays with the handle, and sourcePassword applies only to the imported input

pdfa.convert defaults to raster; preserve keeps text/vector content and invokes veraPDF before output callbacks, then replaces the handle with the verified unencrypted document only after successful output and result publication

Acceptance

Current acceptance requires FPC 3.3.1 or later on every platform and records the actual compiler build and selected source identities

Historical native Linux runs with FPC 3.2.2 and 3.3.1 verified original stream/font/CMap bytes, inherited resources, rotations, AES source/destination revisions, transformed appearances, cyclic resources, reload behavior, rollback, actual PDF/A-4 validation and bounded child lifetime; the corresponding Windows FPC and Delphi runs exercised page imports, and both C++Builder architectures compiled the public headers

Those results retain their original compiler and source identities; FPC versions below 3.3.1 are not a current compatibility target or release gate

sh Tests/Linux/Run-HeadlessPageImportAcceptance.sh
sh Tests/Linux/Run-LinuxABIAcceptance.sh

Page import and preserved archival contracts · Native document workflows