Import XFDF data into PDF forms using C#
An XML Forms Data Format (XFDF) file stores data from forms located in PDF documents. It contains the values of the form fields and can also contain annotations.
Download sampleTo 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— TheStreamobject 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 form field values into a PDF form from a Stream object containing XFDF information:
Register the SDK license before running SDK 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();byte[] xfdfData = File.ReadAllBytes(@"input_forms.xfdf");using MemoryStream xfdfStream = new MemoryStream(xfdfData);gdpicturePDF.LoadFromFile(@"input_forms.pdf");gdpicturePDF.ImportXFDFDataFromStream(xfdfStream, true, true);gdpicturePDF.SaveToFile(@"output.pdf");Register the SDK license before running SDK operations. For setup details, refer to the getting started with .NET SDK guide.
Imports GdPicture14
Dim license As LicenseManager = New LicenseManager()license.RegisterKEY("")Using gdpicturePDF As GdPicturePDF = New GdPicturePDF() Dim xfdfData As Byte() = System.IO.File.ReadAllBytes("input_forms.xfdf") Using xfdfStream As System.IO.MemoryStream = New System.IO.MemoryStream(xfdfData) gdpicturePDF.LoadFromFile("input_forms.pdf") gdpicturePDF.ImportXFDFDataFromStream(xfdfStream, True, True) gdpicturePDF.SaveToFile("output.pdf") End UsingEnd UsingUsed methods
Related topics