Import and Export XFDF Files

XFDF is an XML-like standard from Adobe XFDF (ISO 19444-1:2016) for encoding annotations and forms. It’s compatible with Adobe Acrobat and several other third-party frameworks.

ℹ️ Note: XFDF has various limitations. In most cases, using Instant JSON will result in a smaller file and better synchronization.

Importing XFDF

PSPDFKit Server supports importing annotations from an XFDF file when uploading a document via the /api/documents endpoint. Send a multipart/form-data POST request including the PDF and the XFDF file to import the annotations in the given PDF file. This will replace all existing annotations in the uploaded PDF with the annotations from the uploaded XFDF file. If you want to keep the existing annotations in the document, you can set keep_current_annotations to true:


POST /api/documents
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token="<secret token>"

Content-Disposition: form-data; name="file"; filename="Example Document.pdf"
Content-Type: application/pdf

<PDF data>
Content-Disposition: form-data; name="attachment"; filename="attachment.xfdf"
Content-Type: application/vnd.adobe.xfdf

<annotations data>
Content-Disposition: form-data; name="keep_current_annotations"


Exporting to XFDF

You can export the current annotations of a document as an XFDF file via a GET request to /api/documents/:document_id/document.xfdf. To get the current annotation of a document’s layer, send a GET request to /api/documents/:document_id/layers/:layer_name/document.xfdf:


GET /api/documents/:document_id/document.xfdf
Authorization: Token token="<secret token>"
$ curl "http://localhost:5000/api/documents/abc/document.xfdf" \
   -H "Authorization: Token token=<secret token>"


HTTP/1.1 200 OK
Content-Type: application/vnd.adobe.xfdf

<XFDF data>