Import and Export XFDF Files
PSPDFKit Server has been deprecated and replaced by Document Engine. To start using Document Engine, refer to the migration guide. With Document Engine, you’ll have access to robust new capabilities (read the blog for more information).
XFDF is an XML-like standard from Adobe XFDF (ISO 19444-1:2016) for encoding annotations and form field values. 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
:
Request
POST /api/documents Content-Type: multipart/form-data; boundary=customboundary Authorization: Token token="<secret token>" --customboundary Content-Disposition: form-data; name="file"; filename="Example Document.pdf" Content-Type: application/pdf <PDF data> --customboundary Content-Disposition: form-data; name="attachment"; filename="attachment.xfdf" Content-Type: application/vnd.adobe.xfdf <annotations data> --customboundary Content-Disposition: form-data; name="keep_current_annotations" true --customboundary--
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
:
Request
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>"
Response
HTTP/1.1 200 OK Content-Type: application/vnd.adobe.xfdf <XFDF data>