Documents

Prerender a Document

This endpoint allows you to pre-render documents in background so that they are cached ahead of time by Document Engine.

This speeds up loading times when opening documents via Nutrient Web SDK. The rendering is done asynchronously, and future clients asking for the document will receive the already cached, rendered pages. For more details about how Document Engine caches work, please check out our Cache guide.

You can customize prerendering by providing a range of pages to prerender and an array of scale factors for prerendered images.

⚠️ Note: Prerendering feature requires setting up the Redis cache. All Redis cache keys are set to expire after the configured REDIS_TTL. To opt out of using the REDIS_TTL for prerendered cache keys, set USE_REDIS_TTL_FOR_PRERENDERING to false in your configuration.

post/api/documents/{documentId}/prerender

Request

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

Path parameters

documentIdstring required

The document ID

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.

Request body

scalesinteger[]

Allows to prerender multiple versions of the pages scaled by provided factors.

start_pageinteger

0-based index of the first of the prerendered pages.

end_pageinteger

0-based index of the last of the prerendered pages. If this value is higher than the number of pages in the document, it will be automatically adjusted.

Example request

{
  "scales": [
    1,
    2,
    4
  ],
  "end_page": 3
}

Response

Document Engine started prerendering in the background.

Changes

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