Download Image Preview Bytes

async AsyncCogniteClient.documents.previews.download_page_as_png_bytes(
id: int,
page_number: int = 1,
) bytes

Downloads an image preview for a specific page of the specified document.

Parameters:
  • id (int) – The server-generated ID for the document you want to retrieve the preview of.

  • page_number (int) – Page number to preview. Starting at 1 for first page.

Returns:

The png preview of the document.

Return type:

bytes

Examples

Download image preview of page 5 of file with id 123:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> content = client.documents.previews.download_page_as_png_bytes(id=123, page_number=5)

Download an image preview and display using IPython.display.Image (for example in a Jupyter Notebook):

>>> from IPython.display import Image
>>> binary_png = client.documents.previews.download_page_as_png_bytes(
...     id=123, page_number=5
... )
>>> Image(binary_png)