Import and Export Data

Form class allows you to import data from an XML file to the PDF file using ImportXml method. In order to import data from XML, you need to create an object of Form class and then call the ImportXml method using the FileStream object. Finally, you can save the PDF file using Save method of the Form class.The following code snippet shows you how to import data from XML file.

Export Data to XML from a PDF File

Form class allows you to export data to an XML file from the PDF file using ExportXml method. In order to export data to XML, you need to create an object of Form class and then call the ExportXml method using the FileStream object. Finally, you can close FileStream object andĀ disposeĀ Form object. The following code snippet shows you how to export data to XML file.

Import Data from FDF into a PDF File

Form class allows you to import data from an FDF file to the PDF file using ImportFdf method. In order to import data from FDF, you need to create an object of Form class and then call the ImportFdf method method using the FileStream object. Finally, you can save the PDF file using Save method of the Form class.The following code snippet shows you how to import data from FDF file.

Export Data to FDF from a PDF File

Form class allows you to export data to an FDF file from the PDF file using ExportFdf method. In order to export data to FDF, you need to create an object of Form class and then call the ExportFdf method using the FileStream object. Finally, you can save the PDF file using Save method of the Form class. The following code snippet shows you how to export data to FDF file.

Import Data from XFDF into a PDF File

Form class allows you to import data from an XFDF file to the PDF file using ImportXfdf method. In order to import data from XFDF, you need to create an object of Form class and then call the ImportXfdf method using the FileStream object. Finally, you can save the PDF file using Save method of the Form class. The following code snippet shows you how to import data from XFDF file.

Export Data to XFDF from a PDF File

Form class allows you to export data to an XFDF file from the PDF file using ExportXfdf method. In order to export data to XFDF, you need to create an object of Form class and then call the ExportXfdf method using the FileStream object. Finally, you can save the PDF file using Save method of the Form class. The following code snippet shows you how to export data to XFDF file.

Export values from fields to the JSON file

Aspose.Pdf.Facades provides an alternative API for working with form fields. This snippet demonstrates how to export and import field values using this API.

Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Document
form.BindPdf(_dataDir + "Sample-Form-01.pdf");

// Create XFDF file.
System.IO.FileStream jsonStream = new FileStream("Sample-Form-01.json", FileMode.Create);

// Export data
form.ExportJson(jsonStream);

// Close file stream
jsonStream.Close();

// Close the document
form.Dispose();

Import values to fields from the JSON file

This code snippet demonstrates how to import values into form fields of a PDF document from a JSON file using the Aspose.Pdf.Facades API. The FileStream is used to handle the JSON file.

Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Document
form.BindPdf("Sample-Form-01.pdf");

// Create XFDF file.
System.IO.FileStream jsonStream = new FileStream("Sample-Form-01.json", FileMode.Open);

// Export data
form.ImportJson(jsonStream);

// Close file stream
jsonStream.Close();

// Close the document
form.Dispose();