Skip to content
DemoSampleAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Form Import and Export ​

ComPDFKit supports exporting form field data to XFDF files or importing form data from XFDF files. This is similar to annotation import/export (see Import and Export Annotations), but specifically for form fields (Widget).

Export Form Data ​

You can export form field data to an XFDF file by following these steps:

C#
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
document.ExportWidgetToXFDFPath("exportPath.xfdf", "tempPath");

Import Form Data ​

You can import form field data from an XFDF file to the document by following these steps:

C#
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
document.ImportWidgetFromXFDFPath("importPath.xfdf", "tempPath");

Export Complete Form Properties ​

In addition to exporting form fill values, you can also export complete Widget properties (including position, style, font, color, and all other configuration information). This is useful when you need to fully backup or migrate form structures.

C#
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
document.ExportCustomWidgetFromXFDFPath("exportPath.xfdf", "tempPath");

Import Complete Form Properties ​

You can import complete Widget properties from an XFDF file to the document:

C#
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
document.ImportCustomWidgetFromXFDFPath("importPath.xfdf", "tempPath");

Form Import/Export Method Comparison ​

FunctionMethodDescription
Form fill values import/exportImportWidgetFromXFDFPath / ExportWidgetToXFDFPathOnly import/export form field fill values (user-entered data)
Complete form properties import/exportImportCustomWidgetFromXFDFPath / ExportCustomWidgetFromXFDFPathImport/export complete Widget properties (position, style, configuration, etc.)