Skip to content

documents->thumbnails

documents->thumbnails(string $id, ?PoliPageThumbnailOptions $options = null): array

Generate page thumbnails for a stored document.

Name Type Required Description
$id string required (no description)
$options ?\PoliPage\ThumbnailOptions — (no description)

array

Code When
invalid_options See [errors](../../../production/errors/) for the full description.
MISSING_API_KEY See [errors](../../../production/errors/) for the full description.
INVALID_API_KEY See [errors](../../../production/errors/) for the full description.
ORGANIZATION_PURGED See [errors](../../../production/errors/) for the full description.
ORGANIZATION_PAYMENT_GRACE See [errors](../../../production/errors/) for the full description.
ORGANIZATION_CANCELLED See [errors](../../../production/errors/) for the full description.
ORGANIZATION_MIGRATING See [errors](../../../production/errors/) for the full description.
DOCUMENT_NOT_FOUND See [errors](../../../production/errors/) for the full description.
FORBIDDEN See [errors](../../../production/errors/) for the full description.
DOCUMENT_GONE See [errors](../../../production/errors/) for the full description.
THUMBNAILS_NOT_AVAILABLE See [errors](../../../production/errors/) for the full description.
VALIDATION_ERROR See [errors](../../../production/errors/) for the full description.
QUOTA_EXCEEDED See [errors](../../../production/errors/) for the full description.
OVERAGE_CAP_EXCEEDED See [errors](../../../production/errors/) for the full description.
STORAGE_ACCESS_DENIED See [errors](../../../production/errors/) for the full description.
INTERNAL_ERROR See [errors](../../../production/errors/) for the full description.
unknown_error See [errors](../../../production/errors/) for the full description.
timeout See [errors](../../../production/errors/) for the full description.
network_error See [errors](../../../production/errors/) for the full description.
invalid_response See [errors](../../../production/errors/) for the full description.
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\ThumbnailOptions;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
$documentId = $argv[1] ?? throw new RuntimeException('usage: documents-thumbnails.php <documentId>');
$thumbnails = $client->documents->thumbnails($documentId, new ThumbnailOptions(
width: 320,
format: 'png',
));
foreach ($thumbnails as $thumb) {
$path = sprintf('./thumb-%02d.png', $thumb->page);
file_put_contents($path, base64_decode($thumb->data, strict: true));
echo "wrote {$path} ({$thumb->width}x{$thumb->height})\n";
}