Import XFDF from Databases and Fill PDF Forms in C#

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 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 a PDF form from a Stream object containing XFDF information:

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

Related Topics