Skip to content

client.documents.thumbnails

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

POST /v1/documents/:id/thumbnails — the deployed API expects the options nested under a thumbnails key. 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] (required) - `format:` ["png" | "jpeg"] - `quality:` [Integer] JPEG quality 1-100 (jpeg only) - `pages:` [Array<Integer>] 1-based page indices; default all pages

Array<PoliPage::Thumbnail>

Code When
PoliPage::NotFoundError 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::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