Rendering API for Linux

The following options can be used in the POST /render API:

type Options = {
	width?: number,
	height?: number,
	pageIndex?: number | Array<number> | 'all',
	renderAnnotations?: boolean,
	format?: 'png' | 'jpeg' | 'webp',
};

width/height

The width and height options control the required dimensions of the rendered image.

Either the width or height parameter is required.

If both width and height parameters are missing or were provided at the same time, an HTTP response with the status 400 will be returned:

HTTP/1.1 400 Bad Request
Content-Type: application/json

pageIndex

The optional pageIndex option sets the pages that will be rendered. The allowed values are:

  • number — Renders a single page with this page index

  • Array<number> — Renders a list of pages with these page indexes

  • "all" — Renders all pages in a document

This defaults to rendering all pages if the pageIndex option is missing.

Page indexes are zero-based non-negative integers. If an invalid pageIndex is used, an HTTP response with the status 400 will be returned:

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "description": "`pageIndex` must be a non-negative integer, list of non-negative integers or `all`",
    "reason": "invalid_options"
}

If using a pageIndex for a page that isn’t present in a document, an HTTP response with the status 400 will be returned:

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "description": "Page index is out of bounds.",
    "reason": "no_such_page"
}

renderAnnotations

The optional renderAnnotations option controls whether or not annotations should be rendered. It defaults to true.

format

The optional format option controls the format of the rendered image. The supported values of this option are "png", "jpeg", and "webp".

If not specified, the default rendering format is resolved from the value of the Accept header. If multiple supported image MIME types are present, the rendering format is resolved in this priority order: image/webp, image/jpeg, and image/png. This defaults to image/png if the Accept header is missing or doesn’t contain any supported image MIME type.