When viewing PDF files, we usually use annotations to add more information, such as explanations, review comments, and highlights on the original PDF file’s contents. Sometimes you annotate a PDF documentation, and need to share the annotations with your colleagues who have the same documentation. Transferring the entire file is the most common method. However, it’s extremely inconvenient when it comes to large PDF documents. The more effective way is to export the annotations as separate files and then import them into the PDF file.
The annotation information can be exported in two universal formats—XFDF and FDF. And our SDK supports XFDF. In this blog, we will give a detailed introduction to exporting XFDF annotations.
What Is XFDF?
XFDF is an XML-based standard from Adobe XFDF for encoding annotations. An XFDF file will contain a snapshot of a PDF document’s annotations and forms. It’s compatible with Adobe Acrobat and several other third-party frameworks.
There are many possible uses XFDF can serve, and exchanging PDF annotations and form data between computers independently of the underlying PDF file is the most common. Therefore, XFDF is considered an efficient medium of annotation interchange. ComPDFKit PDF SDK supports both reading and writing XFDF.
Following is a snippet of an XFDF file containing a note annotation:
<?xml version="1.0" encoding="UTF-8"?> <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"> <f href="Document.pdf"/> <ids original="7A0631678ED475F0898815F0A818CFA1" modified="BEF7724317B311718E8675B677EF9B4E" /> <annots> <text flags="print,nozoom,norotate" page="0" subject="Note" rect="271.850464,690.255371,291.850464,708.255371" creationdate="D:20030425095243-07'00'" name="apYVRecPEj75sYIwSxME7C" ... > ... <popup .../> </text> </annots> </xfdf>
Difference Between FDF and XFDF
FDF is short for Forms Data Format. In the FDF format, information is represented in the form of key/value pairs. While XFDF stands for XML Forms Data Format. It is not difficult to see that the XML syntax is used.
FDF and XFDF are both file formats for representing the annotations and form data that are contained in a PDF file. There are two main differences between FDF format and XFDF format:
The syntax that is used for representing information in FDF format is different from the syntax used for representing that same information in XFDF format.
Export XFDF from PDF with Acrobat
Adobe Acrobat can export XFDF annotations from PDF documents.
1. From the options menu in the comments list, choose Export All To Data File.
2. Name the file and choose Acrobat FDF Files (*.fdf) or Acrobat XFDF Files (*.xfdf) for the file type.
3. Specify a location for the file, and then click Save.
Export XFDF from PDF with ComPDFKit
For single end-users, Acrobat is greatly useful. For developers that look to build a document collaboration workflow around PDF, however, a solution allowing to extract annotations to a server will be more preferred. Let’s learn about the solution provided by ComPDFKit PDF SDK.
NSURL *url = [NSURL fileURLWithPath:pdfPath]; CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease]; NSString *path = [NSString stringWithString:xfdfPath]; [document exportAnnotationToXFDFPath:path];
CPDFDocument document = readerView.getPDFDocument(); //the path of xfdf String xfdfPath = context.getCacheDir() + "/xfdf/exportXFDF.xfdf"; //the transfer path of audio and video files String tmpxfdfPath = context.getCacheDir() + "/tmp"; document.exportAnnotations(xfdfPath,tmpxfdfPath);
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath"); document.ExportAnnotationToXFDFPath("xfdfPath","tempPath");
For more related operations like importing XFDF annotations, please visit our guides.
We have seen how to export XFDF annotations in PDF documents, which is convenient for us to save a lot of time and memory by saving and transferring only the annotations instead of an entire PDF file. If you have any questions on this feature, do not hesitate to get in touch with us. We are happy to assist you!