Import XFDF from Files and Fill PDF Forms in C# .NET

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

To import the form 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 a PDF form from an XFDF file:

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
gdpicturePDF.ImportXFDFDataFromFile(@"C:\temp\form.xfdf", true, true);
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    gdpicturePDF.ImportXFDFDataFromFile("C:\temp\form.xfdf", True, True)
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using
Used Methods

Related Topics