Tutorials

Saving Your Collaboration Time by Exporting & Importing Annotations

By ComPDFKit | Fri. 04 Nov. 2022
Annotations

Do you worry about the time-consuming process of sending large, annotated files to colleagues? Previously, we introduced how to export annotations and the difference between the format of XFDF and FDF. For details, please refer to this article. Then today we will sort out the whole process together.

 

In this blog, we will give a further introduction to how to save your collaboration time by importing and exporting annotations with ComPDFKit PDF SDK.

 

 

Export Annotations Using Objective-C, Java, or C#

 

Consider a case where we need to address feedback from different reviewers at the same time. Their feedback could be about technology, content, alignment, etc.

 

In this case, it will be enough for the reviewers to export annotations to XFDF or FDF and share it with the author. so the author can address the feedback quickly without opening multiple copies with different comments.

 

By exporting and importing annotations, it helps you save data transfer costs, time costs, and memory waste due to duplication.

 

Let‘s follow the steps below to export annotations from PDF to XFDF using Objective-C, Java, or C# programming languages.

         - Load the PDF file

         - Export the annotations from PDF to XFDF or FDF

 

Objective-C

NSURL *url = [NSURL fileURLWithPath:pdfPath];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];

NSString *path = [NSString stringWithString:xfdfPath];
[document exportAnnotationToXFDFPath:path];

 

Java

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);

 

C# 

CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
document.ExportAnnotationToXFDFPath("xfdfPath","tempPath");

 

 

Import Annotations Using Objective-C, Java, or C#

 

In the above example, it is easier for the author to import comments to address feedback from multiple different reviewers, saving the time of repeatedly opening the same file with different comments.

 

By importing and exporting annotations, the author can easily remove the annotation marks, saving the time of comparing the original files. And the reviewers can import comments and recheck the PDF file at any time.

 

The following steps show how to export annotations from PDF to XFDF format:

         - Load the PDF file

         - Import the annotations from XFDF or FDF to PDF

 

The following code example demonstrates how to import annotations in a PDF document using Objective-C, Java, or C#.

 

Objective-C

NSURL *url = [NSURL fileURLWithPath:pdfPath];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];

​NSString *path = [NSString stringWithString:xfdfPath];
[document importAnnotationFromXFDFPath:path];

 

Java

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.importAnnotations(xfdfPath,tmpxfdfPath);
readerView.reloadPages();

 

C# 

CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
document.ImportAnnotaitonFromXFDFPath("xfdfPath","tempPath");

 

 

Conclusion

 

There are many more user scenarios for importing and exporting annotations. But without exception, collaboration can be more simple by exporting and importing annotations. You can both quickly confirm whether the marked section has been modified, or if the others have any new feedback on it.

 

For inquiries on how this feature fits into your use case, please contact us. We are looking forward to assisting you!