Documentation
¶
Overview ¶
Package gotenberg is a document.Renderer backed by a Gotenberg server's Chromium HTML route. It talks plain HTTP (no Go SDK), so it depends only on the standard library and the document package.
The request shape follows the Gotenberg docs (https://gotenberg.dev/docs/convert-with-chromium/convert-html-to-pdf, verified 2026-10-20): POST {base}/forms/chromium/convert/html with a multipart form whose "files" field carries a file named "index.html"; a 200 response body is the PDF. Gotenberg answers 400 on a main-page network error, 403 on a forbidden URL, and 409 when a page returns a failing HTTP status.
Index ¶
Constants ¶
const ( // DefaultTimeout bounds one conversion when Config.Timeout is zero. DefaultTimeout = 30 * time.Second // DefaultMaxResponseBytes bounds the PDF read from Gotenberg when // Config.MaxResponseBytes is zero. DefaultMaxResponseBytes int64 = 32 << 20 )
Variables ¶
var ( // ErrResponseTooLarge reports a PDF larger than Config.MaxResponseBytes; // the body is discarded. It also wraps document.ErrRenderRejected. ErrResponseTooLarge = errors.New("gotenberg: response exceeds the configured size limit") // ErrUnexpectedStatus reports a non-2xx response. The error text carries // the status code and the start of Gotenberg's plain-text message. A 400, // 409 or 422 also wraps document.ErrRenderRejected. ErrUnexpectedStatus = errors.New("gotenberg: unexpected response status") )
Sentinel errors callers can branch on via errors.Is.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// BaseURL is the Gotenberg server, e.g. "http://gotenberg:3000". Required;
// it must be an absolute http or https URL. A trailing slash is ignored.
BaseURL string
// HTTPClient sends the requests. Nil uses a new *http.Client; inject one
// to add tracing (otel.Transport), proxies or TLS settings.
HTTPClient *http.Client
// Timeout bounds one conversion, on top of any deadline already on the
// caller's ctx. Zero uses DefaultTimeout.
Timeout time.Duration
// MaxResponseBytes bounds the PDF read into memory. Zero uses
// DefaultMaxResponseBytes.
MaxResponseBytes int64
}
Config configures a Renderer.