This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/annotations/import-xfdf.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Import XFDF annotation data to PDF in C# .NET | Nutrient .NET SDK
XFDF

An XML Forms Data Format (XFDF) file stores annotation and form field data from PDF documents. It contains the annotation structure and the values submitted to it.

Download sample

Importing XFDF data from a file

To import the annotation data from a file, use the ImportXFDFDataFromFile method with the following required parameters:

  • FilePath — The file path of the XFDF file.
  • ImportFormFields — A Boolean value that specifies whether to import the form field data.
  • ImportAnnotations — A Boolean value that specifies whether to import the annotation data.

The example below imports the annotations from an XFDF file:

Register the SDK license before running annotation operations. For setup details, refer to the getting started with .NET SDK guide.

using GdPicture14;
LicenseManager license = new LicenseManager();
license.RegisterKEY("");
using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"input.pdf");
gdpicturePDF.ImportXFDFDataFromFile(@"input.xfdf", true, true);
gdpicturePDF.SaveToFile(@"output.pdf");

Importing XFDF data from a database

To import the annotation data from a database, save the XFDF information from the database as a Stream object, and then use the ImportXFDFDataFromStream method with the following required parameters:

  • Stream — The Stream object containing XFDF information.
  • ImportFormFields — A Boolean value that specifies whether to import the form field data.
  • ImportAnnotations — A Boolean value that specifies whether to import the annotation data.

The example below imports the annotations from a Stream object containing XFDF information:

using GdPicturePDF gdpicturePDFFromStream = new GdPicturePDF();
gdpicturePDFFromStream.LoadFromFile(@"input.pdf");
// Open the XFDF data as a stream. In your application, use the stream that holds the XFDF data from your database.
using FileStream xfdfStream = File.OpenRead(@"input.xfdf");
gdpicturePDFFromStream.ImportXFDFDataFromStream(xfdfStream, true, true);
gdpicturePDFFromStream.SaveToFile(@"output_stream.pdf");