Import and Export

Export Records as an Instant JSON

Use this endpoint to export a document's records as an Instant JSON file. This includes annotations, form field, form field values and bookmarks.

This API allows to optionally specify the Instant JSON schema version for the annotations, controlled via annotation_version query parameter. The value of annotation_version can be any valid positive integer version. If the annotation_version parameter is not mentioned, or is invalid, the latest version of Instant JSON schema will be exported.

get/api/documents/{documentId}/document.json

Request

  • Base URL: http://localhost:5000
  • URL: http://localhost:5000/api/documents/{documentId}/document.json
  • Auth: one of:
    • API key in header Authorization
    • HTTP bearer

Path parameters

documentIdstring required

The document ID

Query parameters

annotation_version1 | 2

The version of Instant JSON schema that should be exported for annotations.

Headers

pspdfkit-pdf-passwordstring

The PDF document password.

The value can be either a plain-text password or a base64 encoded password in a form base64:<encoded-password>. Use the Base64 encoding if your password contains characters that are not allowed in HTTP header or would be otherwise mangled (e.g. trailing or leading spaces)

If the document is password protected, any operations performed on it require supplying a password.

Response

Document Engine returned the Instant JSON file.

format'https://pspdfkit.com/instant-json/v1' required
attachmentsAttachments

Attachments are defined as an associative array.

  • Keys are SHA-256 hashes of the attachment contents or the pdfObjectId of the attachment (in case it's part of the source PDF).
  • Values are the actual Attachment objects with Base-64 encoded binary contents of the attachment and its content type.
skippedPdfObjectIdsinteger[]

An array of PDF object IDs that should be skipped during the import process. Whenever an object ID is marked as skipped, it'll no longer be loaded from the original PDF. Instead, it could be defined inside the annotations array with the same pdfObjectId. If this is the case, the PDF viewer will display the new annotation, which signals an update to the original one. If an object ID is marked as skipped but the annotations array doesn't contain an annotation with the same pdfObjectId, it'll be interpreted as a deleted annotation. An annotation inside the annotations array without the pdfObjectId property is interpreted as a newly created annotation.

Example response

{
  "annotations": [
    {
      "bbox": [
        255.10077620466092,
        656.7566095695641,
        145.91672653256705,
        18.390804597701162
      ],
      "action": {
        "relativePath": "/other_document.pdf"
      },
      "id": "01DNEDPQQ22W49KDXRFPG4EPEQ",
      "createdAt": "2019-09-16T15:05:03.712909Z",
      "updatedAt": "2019-09-16T15:05:03.712909Z",
      "customData": {
        "foo": "bar"
      },
      "rects": [
        [
          100,
          200,
          300,
          400
        ]
      ],
      "color": "#fcee7c",
      "note": "This is a note."
    }
  ],
  "attachments": {
    "388dd55f16b0b7ccdf7abdc7a0daea7872ef521de56ee820b4440e52c87d081b": {
      "binary": "YXR0YWNobWVudCBjb250ZW50cwo=",
      "contentType": "image/png"
    },
    "ccbb4499fa6d9f003545fa43ec19511fdb7227ca505bba9f74d787dff57af77b": {
      "binary": "YW5vdGhlciBhdHRhY2htZW50IGNvbnRlbnRzCg==",
      "contentType": "plain/text"
    }
  },
  "formFields": [
    {
      "id": "7KPSXX1NMNJ2WFDKN7BKQK9KZ",
      "name": "Form-Field",
      "label": "Form Field",
      "annotationIds": [
        "01DNEDPQQ22W49KDXRFPG4EPEQ",
        "7KPS6T4DKYN71VB7G5KBGB5R51"
      ],
      "flags": [
        "required"
      ]
    }
  ],
  "bookmarks": [
    {
      "action": {
        "relativePath": "/other_document.pdf"
      }
    }
  ],
  "comments": [
    {
      "rootId": "01HBDGR9D5JTFERPSCEMNH5GPG",
      "text": {
        "value": "Annotation with <b>xhtml</b> contents."
      },
      "createdAt": "2019-09-16T15:05:03.712909Z",
      "creatorName": "John Doe",
      "updatedAt": "2019-09-16T15:05:03.712909Z"
    }
  ],
  "pdfId": {
    "permanent": "9C3nLxNzQBuBBzv96LbdMg==",
    "changing": "Oi+XccZpDHChV7I="
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.