Skip to content

client.documents.preview

client.documents.preview(id)

GET /v1/documents/:id/preview — returns the stored paginated HTML plus the page count carried by the X-Document-Page-Count response header. The body is text/html, NOT a JSON envelope. No engine work — this is a snapshot read of the stored document.

Name Type Required Description
id String (no description)

PoliPage::DocumentPreviewResult{ html:, page_count: }

Code When
PoliPage::NotFoundError See [errors](../../../production/errors/) for the full description.
PoliPage::GoneError 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.preview — fetch the stored document's
# paginated HTML plus its page count, without re-rendering. The body is
# `text/html`, not a JSON envelope.
require "poli_page"
client = PoliPage::Client.new(api_key: ENV.fetch("POLI_PAGE_API_KEY"))
stored = client.documents.preview("doc_INV-001")
puts "#{stored.page_count} page(s), #{stored.html.length} chars"
File.write("preview.html", stored.html)