Convert Instant JSON to XFDF Using JavaScript

To achieve interoperability between XFDF (XML Forms Data Format) and JSON files that conform to PSPDFKit’s annotation schema, PSPDFKit has APIs for importing JSON data into a PDF and exporting it as XFDF.

Unlike PSPDFKit’s JSON schema, XFDF doesn’t have a concept of differentials for describing changes to a PDF (e.g. deleted annotations, new bookmarks, edited forms). XFDF is instead a representation of all annotation and form data inside a PDF document at a point in time. Since these concepts don’t directly translate to each other, there are some limitations that wouldn’t be represented in the final XFDF.

You can import conforming JSON files when loading the document, and export to XFDF, by using the following code:

const response = await fetch("");
const json = await response.json();
const instance = await PSPDFKit.load({
	instantJSON: json,
	headless: true
const exportedXFDF = await instance.exportXFDF();