PDFium Component Docs

ExportXFDF-methode

Component: TPdf  ·  Unit: PDFium
Serialiseert elke waarde van een formulierveld en annotatie op alle pagina’s van het geladen document naar een XFDF-document (ISO 19444-1), geschreven als UTF-8-XML met de naamruimte http://ns.adobe.com/xfdf/

Syntax

function ExportXFDF(const FileName: string): Integer; overload;
function ExportXFDF(Stream: TStream): Integer; overload;
function ExportXFDFToStream(Stream: TStream): Integer;

Description

ExportXFDF walks every page of the loaded document and produces an ISO 19444-1 conformant XFDF document rooted in the http://ns.adobe.com/xfdf/ namespace. The output consists of a <fields> section and an <annots> section, both emitted as UTF-8 XML.

For form fields, the method enumerates the widget annotations of every page, reads each field value, and writes a <field> element. Hierarchical (qualified) field names are split on the dot separator and emitted as nested <field> elements so that the parent/child structure round-trips. Checkboxes and radio buttons export their export value (the appearance-state name that represents the on state) as the field value. Signature fields are listed but their value is never exported.

Waarde-aanwezigheidsvlaggen houden een expliciet lege veldwaarde gescheiden van een weggelaten waarde, inclusief velden die dieper dan twee niveaus genest zijn

For annotations, every non-widget, non-popup annotation on every page is serialized. The exporter recognizes 18 /Subtype values: text, highlight, underline, strikeout, squiggly, line, circle, square, caret, polygon, polyline, stamp, ink, freetext, fileattachment, sound, link, and redact. Each is written as an element under <annots> carrying its page index, bounding rectangle, contents, title (author), name (NM), subject, modification and creation dates, flags, and color.

Encoding conventions follow ISO 19444-1: colors are written as #RRGGBB hex strings; coordinate lists (rectangle, line endpoints, polygon/polyline vertices, ink lists) are comma-separated numbers; and annotation flags are emitted as a comma-separated list of flag names rather than a raw bitmask.

Bij markeringsannotaties over meerdere regels bevat het attribuut coords elke vierhoek in documentvolgorde in plaats van alleen de eerste regel

Annotatie-inhoud gebruikt dezelfde aanwezigheidssemantiek, zodat een expliciet leeg contents-element de export overleeft zonder een afwezig element in een leeg element te veranderen

PDFium itself exposes no XFDF API. ExportXFDF is implemented entirely in Pascal by PDFiumPas on top of its own annotation and form-field data model, querying PDFium only for the per-annotation attribute values.

Returns the number of UTF-8 bytes written. The Stream overload accepts a TStream to write into; the FileName overload accepts a file path and creates/truncates that file. ExportXFDFToStream is an alias for the Stream overload.

Remarks

Example

// Export all fields and annotations to an .xfdf file
BytesWritten := Pdf1.ExportXFDF('C:\Data\form.xfdf');

// Or to a stream
var
  Stream: TFileStream;
begin
  Stream := TFileStream.Create('C:\Data\form.xfdf', fmCreate);
  try
    Pdf1.ExportXFDF(Stream);
  finally
    Stream.Free;
  end;
end;

See Also

ImportXFDF, Annotation, AnnotationCount, FormFieldInfo