Import and Export
The methods for importing and exporting XFDF annotations allow users to save and restore annotations and form data without altering the original PDF document, facilitating the sharing and processing of documents across different editors or platforms.
Import Annotations
When importing annotations via XFDF, a temporary file directory is created. It is necessary to specify both the XFDF path and the temporary file path during the annotation import.
This example shows how to import annotations:
var document = CPDFDocument(url: URL(string: "filePath"))
document?.importAnnotation(fromXFDFPath: "importFilePath")
CPDFDocument *importDocument = [[CPDFDocument alloc] initWithURL:[NSURL fileURLWithPath:"filePath"]];
[importDocument importAnnotationFromXFDFPath: self.exportFilePath];
Export Annotations
When exporting annotations via XFDF, a temporary file directory is generated. It is essential to specify both the XFDF path and the temporary file path during annotation export.
This example shows how to export annotations:
var document = CPDFDocument(url: URL(string: "filePath"))
document?.exportAnnotation(toXFDFPath: "exportFilePath")
CPDFDocument *importDocument = [[CPDFDocument alloc] initWithURL:[NSURL fileURLWithPath:"filePath"]];
[importDocument importAnnotationFromXFDFPath: "exportFilePath"];
What is XFDF
XFDF (XML Forms Data Format) is an XML format used to describe and transmit PDF form data. It is commonly used in conjunction with PDF files to store and pass values, states, and operations of form fields.
An XFDF file contains data corresponding to a PDF form, including the names, values, options, and formats of form fields.
XFDF serves as a format for describing form data and does not encompass the PDF file itself. It is employed for storing and transmitting form data, facilitating interaction and sharing between different systems and applications.