Last updated: . Every code sample on this page was run against the live API with the sandbox key on that date.
Short answer: http.Post (or http.NewRequest) to https://rendlet.com/v1/pdf with JSON {"html": "..."} and an Authorization: Bearer header; the response body is the PDF. The standard library is enough. Rendlet runs Chromium for you, so your Go binary stays small and your containers don't need a browser.
The public sandbox key needs no signup (5 renders a day per network, 1 page, up to 50 KB, faint watermark).
# Works as-is with the public sandbox key. With your own key: export RENDLET_API_KEY=YOUR_API_KEY
curl -X POST https://rendlet.com/v1/pdf \
-H "Authorization: Bearer ${RENDLET_API_KEY:-sandbox}" \
-H "Content-Type: application/json" \
-d '{"html":"<h1>Hello</h1><p>Rendered by Rendlet.</p>","options":{"format":"A4","margin":"15mm"}}' \
-o hello.pdf
htmlToPDF() helperSave as render.go and run go run render.go. Output when we ran the same HTML via the live sandbox: saved order.pdf (1 page, 12823 bytes); 4 renders left (byte size varies slightly with Chromium).
// Go 1.21+. Save as render.go and run: go run render.go
// Uses the public sandbox key unless you set RENDLET_API_KEY=YOUR_API_KEY
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
type options struct {
Format string `json:"format"`
Margin string `json:"margin"`
}
type requestBody struct {
HTML string `json:"html"`
Options options `json:"options"`
}
func htmlToPDF(html string) (pdf []byte, pages, remaining string, err error) {
key := os.Getenv("RENDLET_API_KEY")
if key == "" {
key = "sandbox"
}
body, err := json.Marshal(requestBody{
HTML: html,
Options: options{Format: "A4", Margin: "15mm"},
})
if err != nil {
return nil, "", "", err
}
req, err := http.NewRequest(http.MethodPost, "https://rendlet.com/v1/pdf", bytes.NewReader(body))
if err != nil {
return nil, "", "", err
}
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 60 * time.Second}
res, err := client.Do(req)
if err != nil {
return nil, "", "", err
}
defer res.Body.Close()
pdf, err = io.ReadAll(res.Body)
if err != nil {
return nil, "", "", err
}
if res.StatusCode < 200 || res.StatusCode >= 300 {
// Errors are JSON, e.g. {"error":"quota_exceeded", ...}
return nil, "", "", fmt.Errorf("Rendlet %d: %s", res.StatusCode, pdf)
}
return pdf, res.Header.Get("X-Pages"), res.Header.Get("X-Quota-Remaining"), nil
}
func main() {
html := `<!doctype html>
<html><body style="font-family:sans-serif;padding:24px">
<h1 style="color:#1f4e79">Order A-1042</h1>
<p>Customer: Globex Corp</p>
<p><b>Total: $2,035.00</b></p>
</body></html>`
pdf, pages, remaining, err := htmlToPDF(html)
if err != nil {
panic(err)
}
if err := os.WriteFile("order.pdf", pdf, 0o644); err != nil {
panic(err)
}
fmt.Printf("saved order.pdf (%s page, %d bytes); %s renders left\n", pages, len(pdf), remaining)
}
Escape or template user-supplied values before putting them into HTML (e.g. html/template), then pass the string to htmlToPDF(). Keep the API key in the process environment on the server.
Write the bytes with Content-Type: application/pdf, or put them in object storage. For serverless or agent callers that prefer JSON, set "response":"base64" in the request body and decode the base64 field.
| Field | Values |
|---|---|
options.format | A4, Letter, Legal, A3, A5 |
options.landscape | true / false |
options.margin | CSS length, e.g. "15mm" or "0" |
options.printBackground | true / false |
filename | Name used in the Content-Disposition header |
response | "binary" (default) or "base64": JSON {filename, pages, bytes, content_type, base64} |
For HTML input, JavaScript in the page is not run, and only data: URIs and public https:// assets (images, fonts, CSS) load. Inline your CSS or link it over https. Simplified Chinese works out of the box (Noto Sans SC is bundled).
Successful renders return X-Pages, X-Plan, X-Quota-Limit and X-Quota-Remaining. Errors are JSON like {"error":"...","message":"..."}: 400 bad request, 401 missing key, 403 invalid key, 413 HTML too large or too many pages, 429 quota exceeded, 500 render failed.
| Sandbox | Free | Starter | Pro | Scale | |
|---|---|---|---|---|---|
| Price | $0 | $0 | $7/mo | $19/mo | $59/mo |
| Documents | 5 / day / network | 100 / month | 1,000 / month | 5,000 / month | 25,000 / month |
| Requests per minute | 3 | 10 | 30 | 60 | 120 |
| Pages per document | 1 | 10 | 50 | 200 | 500 |
| HTML size | 50 KB | 1 MB | 2 MB | 2 MB | 2 MB |
Every plan has a hard monthly cap: at the cap the API returns 429 with an upgrade_url, and you are never billed for overage. Failed renders don't count. Source: docs.