Skip to content

PDF Generation Template Editor

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

View on GitHub

Import or Export Forms ​

If you want to import or export forms with XFDF, you can use exportAnnotations and importAnnotations of annotationManager.

Import Forms ​

After the document is loaded, you can import the field values of XFDF (<fields>) with importAnnotations; each value goes to the field of the same name in the document. The type of XFDF can be String or File

javascript
await annotationManager.importAnnotations(xfdf)

Export Forms ​

After the document is loaded, you can export the field values with exportAnnotations as XFDF string. Passing only the widgets as annotationList leaves out the other annotations. The widgets themselves are saved in the PDF.

javascript
const { Annotations } = instance.Core
const widgets = annotationManager.getAnnotationsList().filter(annotation => annotation instanceof Annotations.WidgetAnnotation)
const xfdfString = await annotationManager.exportAnnotations({ annotationList: widgets, fields: true })