Import and Export Forms
The methods for importing and exporting XFDF forms allow users to save and restore PDF document form data, making it easier to fill out form data.
Import Form
When importing a form via XFDF, a temporary file directory is created. Both the XFDF path and the temporary file path must be specified during the import.
The code for importing a form is as follows:
// the path of xfdf
String xfdfPath = context.getCacheDir().getAbsolutePath() + "/xfdf/exportXFDF.xfdf";
// the transfer path of audio and video files
File tempFilePath = new File(context.getCacheDir(), "tmp");
tempFilePath.mkDirs();
document.importWidgets(xfdfPath,tempFilePath.getAbsolutePath());
// the path of xfdf
val xfdfPath: String = "${context.cacheDir.absolutePath}/xfdf/exportXFDF.xfdf"
// the transfer path of audio and video files
val tempFilePath : File = File(context.cacheDir(), "tmp")
tempFilePath.mkDirs()
// Please make sure the 'tmpxfdfPath' folder exists
document.importWidgets(xfdfPath, tempFilePath.absolutePath)
Export Form
When exporting a form via XFDF, a temporary file directory is created. Both the XFDF path and the temporary file path need to be specified during the export.
The code for exporting a form is as follows:
CPDFDocument document = readerView.getPDFDocument();
// the path of xfdf
File xfdfFile = new File(context.getCacheDir(), "/xfdf/exportXFDF.xfdf");
xfdfFile.getParentFile().mkdirs();
// the transfer path of audio and video files
File tmpXfdfFile = new File(context.getCacheDir(), "/tmp");
tmpXfdfFile.mkdirs();
document.exportWidgets(xfdfFile.getAbsolutePath(),tmpXfdfFile.getAbsolutePath());
val document = readerView.pdfDocument
// the path of xfdf
val xfdfFile = File(context.cacheDir, "/xfdf/exportXFDF.xfdf")
xfdfFile.parentFile?.mkdirs()
// the transfer path of audio and video files
val tmpXfdfFile = File(context.cacheDir, "/tmp")
tmpXfdfFile.mkdirs()
document.exportWidgets(xfdfFile.absolutePath, tmpXfdfFile.absolutePath)
What is XFDF?
XFDF (XML Forms Data Format) is an XML format used to describe and transfer PDF form data. It is typically used with PDF files to store and transmit form field values, states, and operations.
An XFDF file contains data corresponding to a PDF form, including the form field names, values, options, formats, and more.
XFDF is a format used to describe form data and does not contain the PDF file itself. It is used to store and transmit form data for interaction and sharing between different systems and applications.