Marketplace

PDF

Other

HTML → PDF via headless Chromium.

togo-framework
bash
togo install togo-framework/pdf

Install

bash
togo install togo-framework/pdf

togo · pdf

HTML → PDF for togo apps. A swappable render engine (default: headless Chromium via chromedp), a Go API, and a REST endpoint.

bash
togo install togo-framework/pdf

Blank-importing the package registers the pdf provider with the kernel. Pick the engine with PDF_DRIVER (default chromium). The Chromium driver needs a Chrome/Chromium binary available on the host.

Use it

Go:

go
import "github.com/togo-framework/pdf"

svc, _ := pdf.FromKernel(k)
out, err := svc.Render(ctx, "<h1>Invoice</h1><p>Thanks!</p>", pdf.Options{Landscape: false})

RESTPOST /api/pdfapplication/pdf:

bash
curl -X POST localhost:8080/api/pdf \
  -H 'content-type: application/json' \
  -d '{"html":"<h1>Hello</h1>","filename":"hello.pdf"}' \
  --output hello.pdf
# or render a live URL:
curl -X POST localhost:8080/api/pdf -d '{"options":{"url":"https://to-go.dev"}}' --output page.pdf

Options: url, landscape, printBackground, paperWidth/paperHeight (inches, default A4), scale, timeoutSeconds.

Add an engine

Implement pdf.Renderer and pdf.RegisterDriver("wkhtmltopdf", factory) in your plugin's init(), then set PDF_DRIVER=wkhtmltopdf.

MIT © togo


<div align="center"> <h3>Premium sponsors</h3> <p> <a href="https://id8media.com"><strong>ID8 Media</strong></a> &nbsp;·&nbsp; <a href="https://one-studio.co"><strong>One Studio</strong></a> </p> <p><sub>Support togo — <a href="https://github.com/sponsors/fadymondy">become a sponsor</a>.</sub></p> </div>