Skip to content

client.documents.thumbnails

client.documents.thumbnails(id, **options)

POST /v1/documents/:id/thumbnails — the API expects the options nested under a thumbnails key, or an empty body {} when no option is set. Every option is optional; an unset (nil) option is not sent and the API default applies. The SDK does not check bounds: the API answers 400 VALIDATION_ERROR. The response envelope { thumbnails: [...] } is unwrapped here. Returns an Array of PoliPage::Thumbnail; each carries base64-encoded image bytes in data (decode with Base64.decode64(thumb.data)).

Name Type Required Description
id String — (no description)
options Hash — Forwarded to the wire under `thumbnails:`. - `width:` [Integer] 50-2000 px; API default 400 - `format:` ["jpeg" | "webp" | "png"]; API default "jpeg" - `quality:` [Integer] 1-100 (jpeg only) - `pages:` [Array<Integer>] 1-based page numbers; default all pages

Array<PoliPage::Thumbnail>

Code When
PoliPage::NotFoundError See [errors](../../../production/errors/) for the full description.
PoliPage::GoneError See [errors](../../../production/errors/) for the full description.
PoliPage::ValidationError See [errors](../../../production/errors/) for the full description.
PoliPage::PermissionDeniedError See [errors](../../../production/errors/) for the full description.
PoliPage::AuthenticationError See [errors](../../../production/errors/) for the full description.
PoliPage::InvalidResponseError See [errors](../../../production/errors/) for the full description.
PoliPage::InternalError See [errors](../../../production/errors/) for the full description.
PoliPage::APIError See [errors](../../../production/errors/) for the full description.
# frozen_string_literal: true
# Demonstrates: client.documents.thumbnails — get base64-encoded page
# thumbnails for a stored document.
require "base64"
require "poli_page"
client = PoliPage::Client.new(api_key: ENV.fetch("POLI_PAGE_API_KEY"))
thumbs = client.documents.thumbnails(
"doc_INV-001",
width: 320,
format: "png",
pages: [1, 2]
)
# Each entry is a `PoliPage::Thumbnail` carrying base64-encoded image bytes.
thumbs.each do |t|
File.binwrite("page-#{t.page}.png", Base64.decode64(t.data))
puts "page #{t.page}: #{t.width}x#{t.height} #{t.content_type}"
end