Import and Export into FDF

Skip to end of metadata
Go to start of metadata
FDF (Forms Data Format) is infact a Data File which is used to contain the Values of the PDF Form Fields. It is consistitued with Field Name/Field Value Pairs.

The following examples show how to export the PDF Form Field's values into an FDF file and import an FDF's content into a PDF file using the Aspose.Pdf.Kit.Form.

Export the Field's Values into an FDF File

To export the all values of PDF Form Fields, we make use ExportFdf method of Aspose.Pdf.Kit.Form class.Follow these steps to export values to an FDF file:

  1. Instantiate a Form object by passing the input PDF file path as string to the constructor of Form class.
  2. Create a Stream (fdfOutputStream) to hold the new FDF file
  3. Call ExportFdf method of Form class and pass the Stream (fdfOutputStream), holding FDF file to ExportFdf method.
  4. Close the Stream (fdfOutputStream).
[Java]
//Call the custructer of Form.
Form form = new Form();

//Create a new fdf file to contain the content of the pdf.
utputStream fdfOutputStream = new FileOutputStream(path + "Online.fdf");
form.exportFdf(path + "OnlineFilled.pdf", fdfOutputStream);

//Export all the pdf fields' value into the fdf file.
//form.exportFdf(path + "OnlineFilled.pdf", path + "Online.fdf");

//Close the output fdf stream.
fdfOutputStream.close();

//Close the form.
form.close();
 
Import an FDF's content into a PDF File

We can fill PDF Form Fields by importing all values from an FDF file. Aspose.Pdf.Kit.Form class in Aspose.Pdf.Kit. provides ImportFdf method to do this task.Follow these steps to import values from an FDF file:

  1. Instantiate a Form object by passing the input and output PDF file paths as string to the constructor of Form class.
  2. Create a Stream (fdfInputStream) to hold the existing FDF file
  3. Call ImportFdf method of Form class and pass the Stream (fdfInputStream), holding FDF file to ImportFdf method.
  4. Close the Stream (fdfInputStream).
[Java]
//Assign an input and output pdf file.
Form form = new Form(path + "Online.pdf", path + "OnlineFdfout.pdf");

//Import the fdf content into the pdf file.
form.importFdf(path + "Online.fdf");

//Save the output file.
form.close();

//Close the output fdf stream.
fdfInputStream.close();
 
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.