API Overview

PSPDFKit Processor provides a simple HTTP-based API for working with documents.

Processing a Document

To process a document, submit a multipart/form-data request to the POST /process API endpoint.

Available headers for POST /process:

  • Optional — Authorization — This is where you pass in your JSON Web Token (JWT).

  • Optional — pspdfkit-pdf-password — This is where you pass in the password required for the PDF document to be processed. If it’s not set and a password is required, the request will fail.

  • Optional — X-Request-Id — If this is set, log statements associated with the HTTP request are marked with a request_id=<request-id> label. Logs correlated with the same request have the same request ID. This helps you determine which request triggered a specific response and what errors or warnings were emitted during request processing. The request ID needs to be between 20 and 200 characters long.

Available parameters for POST /process:

  • Required — "file", "url", or "generation".

    • "file" — The document that should be processed.

    • "url" — A URL the document that should be processed can be fetched from.

    • "generation" — A JSON object describing how the document should be generated. See the PDF Generation Schema guide for more information.

  • Optional — "operations" — The JSON object describing the operations that should be performed on the supplied document. For all available operations, see the Available Operations guide.

  • Optional — Attachment data for the operations — For example, the XFDF that should be imported when using the applyXfdf document operation.

Request

POST /process
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token="JWT Token"
pspdfkit-pdf-password: "PDF Password"

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

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

<Operations JSON>
--customboundary--
curl -H "Authorization: Token token=JWT_TOKEN" \
  -F file=@Example.pdf \
  -F operations="{\"operations\":[{\"type\": \"flattenAnnotations\"}]}" \
  http://localhost:5000/process \
  --output result.pdf

Response

HTTP/1.1 200 OK
Content-Type: application/pdf

<PDF data>

To see Processor in action, refer to the Usage Examples guide.