Golang HTML to PDF
HTML to PDF Golang API and the Chromedp Alternative for Go Services
Turn an html/template result or a live URL into a searchable, pixel accurate PDF with one HTTP call from Go. Managed Chromium renders your real CSS, web fonts and JavaScript, so you keep chromedp, Rod and the archived wkhtmltopdf wrappers out of your container. Try it on any URL or HTML below.
- PDF and archive in one call
- Plans from $49 a month
- Your HTML stays yours
Live demo
Runs in your browser. Nothing is uploaded. One PDF free to try, then a plan.
Your HTML
Live preview
Your PDF is downloading. That was the free one. The Starter plan converts as many as you need, for $49 a month or $288 a year, half price.
See the planShort answer
To convert HTML to PDF in Golang, execute your html/template into a string and hand it to a renderer. Go has no built in HTML layout engine, so the options are chromedp or Rod, which drive Chromium and require a browser inside your image, a wkhtmltopdf wrapper, which depends on a project archived in 2023, or a rendering API called with net/http. SitePDF renders in managed Chromium and returns a true vector PDF with selectable text, plus an optional dated archive of exactly what it produced.
Written and fact checked by the SitePDF team.
Five ways to make a PDF from Go, compared
Go has no standard library PDF renderer, and the language is usually chosen for small static binaries, which is exactly what a browser dependency undoes. These routes differ on engine, what you must install and run, and whether your existing CSS survives.
| Approach | Engine | CSS and JavaScript | What you run | Best for |
|---|---|---|---|---|
| chromedp Chromium over CDP |
Chromium, driven from Go with Page.PrintToPDF | Full modern CSS and JavaScript | Chromium installed in your image, plus pool and crash handling | Services where owning a browser is acceptable |
| Rod Chromium over CDP |
Chromium, higher level Go API | Full modern CSS and JavaScript | Chromium in your image, rod can download its own build | Teams who prefer a Puppeteer style API in Go |
| go-wkhtmltopdf wrappers legacy |
wkhtmltopdf, an old WebKit fork | Dated CSS, no flexbox or grid, unreliable JavaScript | A wkhtmltopdf binary per platform | Existing services with a migration planned |
| gofpdf, fpdf forks, Maroto draw in code |
No HTML engine, you place text and boxes in Go | None, you do not use CSS | Nothing external | Labels, tickets and fixed structured documents |
| Managed Chromium API SitePDF |
Chromium, run and scaled by us | Full modern CSS and JavaScript | One HTTP call, no browser in your container | Invoices, statements, reports and a dated record |
The honest read: chromedp and Rod are excellent and give you the same Chromium output we do at no license cost, if you are willing to ship and scale a browser. The drawing libraries are the right tool when there is no HTML version of the document. An API earns its place when a browser does not belong in a scratch or distroless image, when volume is spiky, or when you need a retrievable, timestamped copy of what you generated.
The wkhtmltopdf wrappers are the first thing to retire
Search Go PDF questions and the oldest answers point at wrappers around wkhtmltopdf. The underlying project was archived in 2023, which means no further fixes of any kind, security included, and its engine is an old WebKit fork. A template with flexbox or grid will not lay out, web fonts are fragile and JavaScript rendered content is a coin flip. A wrapper also forces you to install a native binary in every image, which cancels the main reason people pick Go. If you run one today, pin the binary and plan the move. The same story, from the other side of the fence, is told on the wkhtmltopdf alternative page.
chromedp and Rod put a browser next to your binary
Both libraries talk to Chromium over the DevTools protocol and call Chromium's print to PDF, so the output matches Chrome's print preview. That is the fidelity you want. The bill arrives in operations. Chromium has to exist in the image, which means a base image with fonts and shared libraries instead of scratch. Each render holds a browser tab that can use hundreds of megabytes on a heavy page, a hung page needs a context timeout and a kill, and a month-end burst needs a worker pool you size for the peak rather than the average. None of that is hard, and plenty of teams run it happily. It is a standing cost, and it is the part an API removes. Gotenberg is the usual middle path: an open source Docker service that wraps Chromium behind an HTTP API, so the browser lives outside your Go binary. You still host, patch and scale that container yourself, which makes it the cheapest route when you want to own the infrastructure and a poor one when you do not. The cost side of the same decision for Node is worked through in the Puppeteer alternative page and, with real arithmetic, in the Playwright production cost article.
The API path from Go is about thirty lines
Render the template to a string exactly as you would for chromedp, then post it. There is nothing to import beyond the standard library.
var buf bytes.Buffer
if err := invoiceTmpl.Execute(&buf, invoice); err != nil {
return err
}
body, _ := json.Marshal(map[string]any{
"html": buf.String(),
"format": "Letter",
"archive": true,
})
req, _ := http.NewRequestWithContext(ctx, "POST",
"https://api.sitepdf.com/v1/render", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("SITEPDF_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
var out struct {
PDFURL string `json:"pdf_url"`
}
json.NewDecoder(resp.Body).Decode(&out)Your CSS, fonts and any chart script render as they do in Chrome, the text stays selectable, and a traffic spike becomes an HTTP concurrency question instead of a memory incident in your pod. Put the call behind a worker or a queue for batch jobs and use the request context for timeouts. Every parameter is listed on the PDF generator API page, and bulk runs are covered on bulk HTML to PDF.
When to use a drawing library instead
If the document has no HTML version and never will, a shipping label, a ticket, a certificate with a fixed layout, then a code drawn PDF is simpler and faster than any renderer. The original gofpdf was archived, so look at the maintained forks or at Maroto, which builds on top of one. The price is that the layout lives in Go code and drifts from your web pages. Use a drawing library when there is no page to mirror, and a renderer when there is one.
Keep a dated copy of every document you generated
An invoice or statement that leaves your service leaves nothing verifiable behind. Send archive: true and SitePDF also stores a timestamped, immutable snapshot of exactly what it rendered, retrievable by id, so you can show what a customer saw on a given date. The website archiving page explains the record. Leave it off and we return the PDF and store nothing.
Rust is the other compiled option
Teams in Rust face the same Chromium decision. The Rust version of the cost breakdown covers the headless Chrome crates against an API call from reqwest.
curl https://api.sitepdf.com/v1/render \
-H "Authorization: Bearer $SITEPDF_KEY" \
-F url=https://app.example.com/invoices/8842 \
-F format=Letter \
-F print_background=true \
-F archive=true
{
"pdf_url": "https://api.sitepdf.com/v1/documents/doc_go41c.pdf",
"pages": 2,
"rendered_in_ms": 1480,
"archive": {
"id": "arc_go73e",
"captured_at": "2026-11-15T09:12:44Z"
}
}
This is the documented API call shape. Full request and response walkthrough.
Questions about this job
How do I convert HTML to PDF in Golang?
Is chromedp good for generating PDFs?
Is there a pure Go HTML to PDF library?
Should I still use a wkhtmltopdf wrapper in Go?
How much does a Go HTML to PDF API cost?
Index
More PDF and archiving tools
- Convert HTML to PDF
- Webpage to PDF
- URL to PDF API
- Website archiving
- Monitor website changes
- Screenshot API
- React to PDF
- Java PDF library
- C# PDF library
- Python PDF generation
- HTML to PDF Node.js
- Laravel HTML to PDF
- Vue to PDF
- Next.js PDF generator
- Angular to PDF
- Markdown to PDF API
- Django HTML to PDF
- Blazor HTML to PDF
- Spring Boot HTML to PDF
- Airtable to PDF
- Svelte to PDF
- Rotativa alternative
- Zapier and Make HTML to PDF
- Rails HTML to PDF
- PDF generator API
- Website archiving software
- Document generation API
- Legal document automation software
- Document automation software
- Bulk HTML to PDF
- Accessible PDF generation
- ADA compliance audit cost
- 508 compliance testing
- PDF remediation
- VPAT and ACR
- PDF accessibility checker
- Wayback Machine alternative
- Best HTML to PDF API
- DocRaptor alternative
- Puppeteer alternative
- Wkhtmltopdf alternative
- PDFShift pricing and alternative
- Urlbox pricing and alternative
- PDFCrowd alternative
- Api2Pdf alternative
- Browserless alternative
- APITemplate alternative
- CraftMyPDF alternative
- PDFMonkey alternative
- dompdf alternative
- WeasyPrint alternative
- jsPDF alternative
- mPDF alternative
- Website archiving pricing comparison
- HTML to PDF API for ecommerce
- HTML to PDF API for SaaS
- HTML to PDF API for accounting software
- PHP convert HTML to PDF
- PrinceXML alternative
- PDFreactor alternative
- PDF integrity check
- Invoice PDF archive
- PDF page numbers, headers and footers
- PDF of pages behind a login
- Website archiving for law firms
- React PDF renderer alternative
- Gotenberg alternative
- GrabzIt alternative
- Adobe PDF Services API
- PDF SDK pricing
- HTML to image API pricing
- Adobe Document Generation API pricing
- jsreport pricing
- PDFBolt pricing
- PDFEndpoint pricing
- Formstack Documents pricing
- Documint pricing
- iLovePDF API pricing
- Browserless pricing
- PandaDoc API pricing
- CloudConvert API pricing
- Encodian pricing
- IronPDF pricing
- Salesforce document generation pricing
- Winnovative pricing
- SelectPdf, HiQPdf and EvoPdf pricing
- CloudConvert alternative
- Direct mail API pricing
- E-signature API pricing
- Sparticuz Chromium Lambda cost
- Browserbase pricing
- Aspose PDF pricing
- PDF API pricing
- How it works
- Features
- Pricing
Get started
Render and archive with one API call
A pixel perfect PDF and a dated copy of the page from the same request. Plans from $49 a month, half price billed yearly.