TXfdfField = record
Name: XFDFString;
Value: XFDFString;
HasValue: Boolean;
Children: array of TXfdfField;
Values: TXfdfWideStrings;
RichText: XFDFString;
HasRichText: Boolean;
end;
TXfdfExportOptions = record
SourceFileName: AnsiString;
FileIdOriginal: AnsiString;
FileIdModified: AnsiString;
NamespaceAttributes: TXfdfNameValuePairs;
end;
TXfdfImportResult = record
Fields: TXfdfFieldArray;
Annotations: TXfdfParsedAnnotationArray;
SourceFile: AnsiString;
FileIdOriginal: AnsiString;
FileIdModified: AnsiString;
NamespaceAttributes: TXfdfNameValuePairs;
end;
TFdfImportResult = record
Fields: TXfdfFieldArray;
SourceFile: XFDFString;
end;
function XfdfExportToStream(Stream: TStream; const Fields: array of TXfdfField;
const Annotations: array of TXfdfAnnotationExport;
const Options: TXfdfExportOptions;
const SubtypeToElementName: array of AnsiString): Integer;
function XfdfExportToFile(const FileName: string; const Fields: array of TXfdfField;
const Annotations: array of TXfdfAnnotationExport;
const Options: TXfdfExportOptions;
const SubtypeToElementName: array of AnsiString): Integer;
function XfdfImportFromStream(Stream: TStream): TXfdfImportResult;
function XfdfImportFromFile(const FileName: string): TXfdfImportResult;
function FdfExportToStream(Stream: TStream; const Fields: array of TXfdfField;
const SourceFileName: AnsiString = ''): Integer;
function FdfExportToFile(const FileName: string; const Fields: array of TXfdfField;
const SourceFileName: AnsiString = ''): Integer;
function FdfImportFromStream(Stream: TStream): TFdfImportResult;
function FdfImportFromFile(const FileName: string): TFdfImportResult;
function XfdfFindAttribute(const Annot: TXfdfParsedAnnotation;
const Name: AnsiString; out Value: AnsiString): Boolean;
function XfdfFindAttr(const Attrs: TXfdfNameValuePairs;
const Name: AnsiString; out Value: AnsiString): Boolean;
FPdfXfdf provides the Pascal-level XFDF and FDF data model and serialization. It is the engine behind TPdf.ExportXFDF, TPdf.ImportXFDF, TPdf.ExportFDF, and TPdf.ImportFDF, but it can also be used directly without an open PDF
XFDF export and import exchange field values and annotations through UTF-8 XML, while FDF export and import exchange the shared field tree through ISO 32000 PDF-like object syntax
XFDF import requires a single completed root element and matching qualified closing tags, checks quoted and separated attributes for duplicate names, and rejects malformed or unknown character references and unsupported declarations such as DTDs
Empty fields and annots containers leave following siblings intact, and unknown extension subtrees are skipped with bounded nesting while respecting comments, processing instructions, and CDATA boundaries
Text values support the five predefined XML entities and decimal or lowercase-x hexadecimal character references for valid Unicode scalars, together with CDATA and intervening comments or processing instructions; this parser does not perform complete XML schema or namespace validation
The FDF parser supports direct and indirect hierarchical field dictionaries, escaped literal strings, hexadecimal strings, PDFDocEncoding, UTF-16 text, name values, arrays, comments, and explicit empty values
XfdfFindAttribute and XfdfFindAttr are convenience lookups for reading attributes off a parsed annotation or its raw name-value pair list
| Function | Description |
|---|---|
XfdfExportToStream | Serializes fields and annotations to a stream as UTF-8 XFDF and returns the byte count |
XfdfExportToFile | Serializes fields and annotations to a file as UTF-8 XFDF and returns the byte count |
XfdfImportFromStream | Parses an XFDF stream into fields, annotations, and file identifiers |
XfdfImportFromFile | Parses an XFDF file into fields, annotations, and file identifiers |
FdfExportToStream | Serializes fields to a stream as FDF and returns the byte count |
FdfExportToFile | Serializes fields to a file as FDF and returns the byte count |
FdfImportFromStream | Parses an FDF stream into hierarchical fields and the optional source file |
FdfImportFromFile | Parses an FDF file into hierarchical fields and the optional source file |
XfdfFindAttribute | Looks up a named attribute on a parsed annotation and returns its value |
XfdfFindAttr | Looks up a named attribute in a name-value pair array |
| Type | Description |
|---|---|
XFDFString | String type used for XFDF text (UnicodeString on Delphi, WideString on FPC) |
TXfdfNameValuePair | Record holding one decoded XML attribute as a Name and Value pair of AnsiString |
TXfdfNameValuePairs | Dynamic array of decoded XML name-value pairs |
TXfdfWideStrings | Dynamic array of XFDF text values |
TXfdfField | Record describing one form field: Name is the partial field name, Value and HasValue carry the current value, Values collects every parsed value element for multi-value fields, Children nests child fields for hierarchical names, and RichText holds the value-richtext content: its XHTML markup as written, or unescaped plain text when it holds no element. On export, rich text that starts with < is written as markup and anything else is escaped |
TXfdfFieldArray | Dynamic array of form field records; the shared field tree type used by both XFDF and FDF results |
TXfdfAnnotationExport | Record describing one annotation for export, including PageIndex, Subtype, Flags, HasColor and colour pairs, Rectangle, and geometry, plus ContentsText, AuthorText, Subject, ModificationDate, CreationDate, Icon, Opacity, Appearance, HasAppearance, ColorHex, Coords, Action, Destination, HasAction, HasContents, HasDestination, HasInkList, HasInteriorColor, HasLineEndpoints, HasOpacity, HasPopup, HasRichText, HasVertices, InReplyTo, InkGestures, InteriorColorHex, LineEnd, LineStart, Name, PopupOpen, ReplyType, RichText, and Vertices |
TXfdfAnnotationExportArray | Dynamic array of annotation export descriptors |
TXfdfParsedAnnotation | Record describing one annotation parsed from an XFDF document, including PageIndex, ElementName, the raw Attributes name-value pairs, Contents, Action, Destination, and geometry, plus Appearance, HasAppearance, HasAction, HasContents, HasDestination, HasPopup, HasRichText, InkGestures, PopupOpen, RichText, and Vertices |
TXfdfParsedAnnotationArray | Dynamic array of annotations parsed from an XFDF document |
TXfdfExportOptions | Record carrying SourceFileName, emitted as the source file element, FileIdOriginal and FileIdModified, emitted together as the file identifier element, and NamespaceAttributes, emitted as additional namespace declarations on the root element |
TXfdfImportResult | Result record bundling the parsed Fields tree, the parsed Annotations, the SourceFile reference, the FileIdOriginal and FileIdModified identifiers, and the NamespaceAttributes captured from the root element |
TFdfImportResult | Result record bundling the parsed FDF Fields tree and the optional SourceFile target read from the /F entry |
SubtypeToElementName open array maps integer annotation subtypes to XFDF element names so export matches the Adobe XFDF schema/V array contains several values, Values retains the decodable scalars and Value returns the first one