Skip to content
Guides

Import and Export Forms

The methods for importing and exporting XFDF forms allow users to save and restore PDF document form data, making it easier to fill out form data.

Import Form

When importing a form via XFDF, a temporary file directory is created. Both the XFDF path and the temporary file path must be specified during the import.

The code for importing a form is as follows:

swift
var document = CPDFDocument(url: URL(string: "filePath"))
document?.importForm(fromXFDFPath: "importFilePath")
objective-c
CPDFDocument *importDocument = [[CPDFDocument alloc] initWithURL:[NSURL fileURLWithPath:@"filePath"]];
[importDocument importFormFromXFDFPath: @""importFilePath""];

Export Form

When exporting a form via XFDF, a temporary file directory is created. Both the XFDF path and the temporary file path need to be specified during the export.

The code for exporting a form is as follows:

swift
var document = CPDFDocument(url: URL(string: "filePath"))
document?.exportForm(toXFDFPath: "exportFilePath")
objective-c
CPDFDocument *importDocument = [[CPDFDocument alloc] initWithURL:[NSURL fileURLWithPath:@"filePath"]];
[importDocument importFormFromXFDFPath: @"exportFilePath"];

What is XFDF?

XFDF (XML Forms Data Format) is an XML format used to describe and transfer PDF form data. It is typically used with PDF files to store and transmit form field values, states, and operations.

An XFDF file contains data corresponding to a PDF form, including the form field names, values, options, formats, and more.

XFDF is a format used to describe form data and does not contain the PDF file itself. It is used to store and transmit form data for interaction and sharing between different systems and applications.