Import or Export Annotations from PDF to XFDF using C# VB.NET

import export pdf xfdf annotations

Annotations are often used to add clarifications, explanations, details, or comments to some documents. In PDF files, annotations are frequently used and you might need to import or export them to XFDF format. You can easily import or export annotations programmatically using C# or VB.NET. Let us go through the following contents:

Annotations Importer or Exporter API – Installation

Aspose.PDF for .NET API exposes different classes, properties, and methods to work with PDF files. Likewise, you can import or export annotations from PDF documents to the XFDF file with PDFAnnotationEditor class. It exposes different methods that can be used to import or export annotations programmatically. You need to install the API by downloading it from New Releases, or via NuGet solution manager in Microsoft Visual Studio IDE. The following command can be used to install the API:

PM> Install-Package Aspose.Pdf

Import Annotations from XFDF to PDF using C# or VB.NET

You can import annotations into PDF file from existing XFDF file in your .NET based applications using C# or VB.NET programming languages. The API supports importing different types of annotations as listed under the AnnotationType Enumeration in API references. Let us follow the following steps to import annotations from XFDF to PDF using C# or VB.NET programming languages in your .NET framework based applications.

  1. Initialize PdfAnnotationEditor class object
  2. Load the input PDF document
  3. Load the XFDF file to import annotations
  4. Specify the annotation types that you want to import
  5. Import annotations from XFDF to PDF file
  6. Save the output PDF file

The code snippet below shows how to import annotations from XFDF file to PDF file using C# or VB.NET:

Export Annotations from PDF to XFDF File using C# or VB.NET

Exporting of annotations from PDF files can be helpful for making the file presentable or for keeping intact only a specific type of annotations. For example, when someone is reviewing a feasibility report or a thesis submission, let us assume, they may highlight some text, add comments or text. Later they want to keep only the text before sending the PDF back to the author. In such scenarios, exporting of annotations to XFDF can help because it lets you export specific annotations as per your requirements. The following steps show how to export annotations from PDF to XFDF format:

  1. Initialize PdfAnnotationEditor object
  2. Load input PDF file
  3. Create XFDF file to save exported annotations
  4. Specify annotation type to Export
  5. Export the annotations with the ExportAnnotationsXfdf method

The code snippet below shows how to export annotations from PDF file to XFDF file using C# or VB.NET:

Conclusion

In this article, we have explored how to import and export annotations from PDF to XFDF format. We have explored different examples and scenarios where importing or exporting the annotations can be helpful. Likewise, there are many use cases and scenarios where this feature is valuable. If you want to discuss any scenario then feel free to contact us at Free Support Forum. You can also explore the API by learning from API Documentation as well as API References. We look forward to hearing from you!

See Also

Rotate PDF Pages, the Text or Image with C# or VB.NET