Documents.Thumbnails
func (d *Documents) Thumbnails(ctx context.Context, id string, options ThumbnailOptions, opts ...option.RequestOption) ([]Thumbnail, error)Thumbnails generates page thumbnails for a stored document. Every option is optional: pass a zero ThumbnailOptions for the API defaults (400 px wide JPEG, every page).
The deployed API expects the options wrapped under a top-level “thumbnails” key on the wire and returns the array under the same key — both are handled here so callers see a plain slice. With no option set the body is {}.
Spec §6.3.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
ctx | context.Context | required | (no description) |
id | string | required | (no description) |
options | ThumbnailOptions | required | (no description) |
opts | ...option.RequestOption | — | (no description) |
Returns
Section titled “Returns”[]Thumbnail, error
Errors
Section titled “Errors”| Code | When |
|---|---|
DOCUMENT_NOT_FOUND | No stored document matches the supplied id. |
DOCUMENT_GONE | The document was deleted or has expired. |
INVALID_API_KEY | The API key is malformed or revoked. |
INTERNAL_ERROR | API returned 5xx. Retryable. |
VALIDATION_ERROR | A ThumbnailOptions value is out of range (width 50-2000, quality 1-100). |
THUMBNAILS_NOT_AVAILABLE | The organization's plan does not include thumbnails. |
Example
Section titled “Example”// Demonstrates: client.Documents.Thumbnails(ctx, id, options) — page thumbnails for a stored document.package main
import ( "context" "fmt" "os"
polipage "github.com/poli-page/sdk-go" "github.com/poli-page/sdk-go/option")
func main() { client := polipage.NewClient( option.WithAPIKey(os.Getenv("POLI_PAGE_API_KEY")), )
thumbnails, err := client.Documents.Thumbnails( context.Background(), "doc_abc123", polipage.ThumbnailOptions{ Width: 840, Format: polipage.ThumbnailFormatPNG, Pages: []int{1, 2}, }, ) if err != nil { panic(err) }
// Each entry includes the image bytes base64-encoded. for _, t := range thumbnails { fmt.Printf("Page %d: %dx%d %s (%d base64 chars)\n", t.Page, t.Width, t.Height, t.ContentType, len(t.Data)) }}