Download Image Preview to Path

async AsyncCogniteClient.documents.previews.download_page_as_png(
path: Path | str | IO,
id: int,
page_number: int = 1,
overwrite: bool = False,
) None

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

Parameters:
  • path (Path | str | IO) – The path to save the png preview of the document. If the path is a directory, the file name will be ‘[id]_page[page_number].png’.

  • 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.

  • overwrite (bool) – Whether to overwrite existing file at the given path. Defaults to False.

Examples

Download Image preview of page 5 of file with id 123 to folder “previews”:

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