Import Annotations

You can import annotations into an input file by sending a request to the /process endpoint and including an Instant JSON or XFDF attachment that contains annotations.

Instant JSON files are imported via the applyInstantJson operation, whereas you can use the applyXfdf operation to import XFDF files.

Before you get started, make sure that Processor is up and running.

Importing Instant JSON into a File on Disk

Send a request to the /process endpoint, attaching an input file and the Instant JSON attachment:

curl -X POST http://localhost:5000/process \
  -F file=@/path/to/example.pdf \
  -F 'instant_json=@/path/to/instant.json;type=application/json' \
  -F operations='{
  "operations": [
    {
      "type": "applyInstantJson",
      "dataFilePath": "instant_json"
    }
  ]
}' \
  -o result.pdf 
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

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

<PDF data>
--customboundary
Content-Disposition: form-data; name="instant_json"; filename="instant.json"
Content-Type: application/json

<Instant JSON data>
--customboundary
Content-Disposition: form-data; name="operations"
Content-Type: application/json

{
  "operations": [
    {
      "type": "applyInstantJson",
      "dataFilePath": "instant_json"
    }
  ]
}
--customboundary--

Note that the operation’s dataFilePath references the request attachment with the same name: instant_json.

Importing Instant JSON into a File from a URL

Attach an Instant JSON file like you did in the previous example, but instead of a file on disk, include a URL pointing to the input file:

curl -X POST http://localhost:5000/process \
  -F url=https://pspdfkit.com/downloads/examples/paper.pdf \
  -F 'instant_json=@/path/to/instant.json;type=application/json' \
  -F operations='{
  "operations": [
    {
      "type": "applyInstantJson",
      "dataFilePath": "instant_json"
    }
  ]
}' \
  -o result.pdf 
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="url"

https://pspdfkit.com/downloads/examples/paper.pdf
--customboundary
Content-Disposition: form-data; name="instant_json"; filename="instant.json"
Content-Type: application/json

<Instant JSON data>
--customboundary
Content-Disposition: form-data; name="operations"
Content-Type: application/json

{
  "operations": [
    {
      "type": "applyInstantJson",
      "dataFilePath": "instant_json"
    }
  ]
}
--customboundary--

Importing an XFDF File

Similar to the Instant JSON import, you can import XFDF files via the applyXfdf operation. Make sure that the XFDF attachment has its content type set to application/vnd.adobe.xfdf.