Documents.Preview
func (d *Documents) Preview(ctx context.Context, id string, opts ...option.RequestOption) (*DocumentPreviewResult, error)Preview retrieves a stored document’s paginated HTML. The engine does no work — this is a cheap read.
The deployed API returns the HTML as text/html (not a JSON envelope) and the page count via the X-Document-Page-Count response header. Missing or unparseable headers are tolerated: PageCount defaults to 0.
Spec §6.2.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
ctx | context.Context | required | (no description) |
id | string | required | (no description) |
opts | ...option.RequestOption | — | (no description) |
Returns
Section titled “Returns”*DocumentPreviewResult, 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. |
Example
Section titled “Example”// Demonstrates: client.Documents.Preview(ctx, id) — get a stored document's HTML preview.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")), )
preview, err := client.Documents.Preview(context.Background(), "doc_abc123") if err != nil { panic(err) }
// preview.HTML is the server-rendered HTML with the stored document's data // applied to its template — useful for in-browser previews without a PDF. fmt.Printf("Preview: %d pages, HTML length %d\n", preview.PageCount, len(preview.HTML))}