Render input
Every render method (Render.PDF, Render.PDFStream, Render.Document, and the RenderToFile helper) takes one input type, polipage.RenderInput. It names a template of a project, and the render uses the project’s copy published in the API key’s environment. There is no version to pin and no inline-HTML input.
Fields
Section titled “Fields”Project,Template(required) — the project and template slugs.Data(required) — the values that fill the template. An emptymap[string]any{}is sent as{}.Format,Orientation,Locale(optional) — override the template’s page format, orientation and locale.Metadata(optional) — your own primitive values, stored with the document and echoed back.
Unset optional fields are left out of the request.
pdf, err := client.Render.PDF(ctx, polipage.RenderInput{ Project: "billing", Template: "invoice", Data: map[string]any{"invoiceNumber": "INV-001", "total": 1280}, Format: polipage.PageFormatA4, Orientation: polipage.OrientationPortrait,})To publish a template, publish its project to the key’s environment. To try a template or raw HTML without an API key, use the playground at play.poli.page. The stored HTML of a document you already rendered stays available through Documents.Preview.
Example
Section titled “Example”package main
import ( "context" "os"
"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")))
if _, err := client.Render.PDF(context.Background(), polipage.RenderInput{ Project: "getting-started", Template: "welcome", Data: map[string]any{"name": "SDK Demo"}, }); err != nil { panic(err) }}