https://gotenberg.dev/

Go client for Gotenberg — document conversion service supporting Chromium, LibreOffice, and PDF manipulation engines.

go get github.com/nativebpm/gotenberg

Features

Conversion Engines

Chromium

Convert web content to PDF:

  • URL → PDF

  • HTML file → PDF

  • Markdown → PDF

Supports:

  • Custom page properties (size, margins, orientation)

  • Headers & footers with page numbers

  • Wait strategies (delay, JavaScript expression)

  • Cookies & custom HTTP headers

  • Emulated media types (screen/print)

LibreOffice

Convert Office documents:

  • Word (.docx, .doc) → PDF

  • Excel (.xlsx, .xls) → PDF

  • PowerPoint (.pptx, .ppt) → PDF

  • OpenDocument formats → PDF

PDF Engines

PDF operations:

  • Merge multiple PDFs

  • Split pages

  • Convert images to PDF

Webhook Mode

Async conversions with callbacks:

  • Returns 204 No Content immediately

  • Uploads result to webhook URL in background

  • Separate error callback URL

  • Custom HTTP headers for callbacks

See Gotenberg webhook docs for details.

Example with Docker:

docker run \
  -p 3000:3000 \
  --name gotenberg \
  --add-host="host.docker.internal:host-gateway" \
  gotenberg/gotenberg:8
package main

import (
 "context"
 "io"
 "log"
 "net/http"
 "os"
 "time"

 "github.com/nativebpm/gotenberg"
)

func main() {
 client, err := gotenberg.NewClient(&http.Client{}, "http://localhost:3000")
 if err != nil {
  log.Fatal(err)
 }

 // Convert web page from URL to PDF
 resp, err := client.
  Chromium().
  ConvertURL(context.Background(), "https://gotenberg.dev/docs/getting-started/introduction").
  PaperSizeA4().
  Margins(1, 1, 1, 1).
  PrintBackground().
  Timeout(30 * time.Second).
  Send()
 if err != nil {
  log.Fatal(err)
 }
 defer resp.Body.Close()

 f, err := os.Create("converturl-chromium.pdf")
 if err != nil {
  log.Fatal(err)
 }
 defer f.Close()

 _, err = io.Copy(f, resp.Body)
 if err != nil {
  log.Fatal(err)
 }

 log.Println("PDF generated from URL: converturl-chromium.pdf")
}
package main

import (
 "context"
 "io"
 "log"
 "net/http"
 "os"
 "strings"

 "github.com/nativebpm/gotenberg"
)

func main() {
 client, err := gotenberg.NewClient(&http.Client{}, "http://localhost:3000")
 if err != nil {
  log.Fatal(err)
 }

 html := strings.NewReader("<html><body><h1>Hello World!</h1></body></html>")

 resp, err := client.Chromium().
  ConvertHTML(context.Background(), html).
  PaperSizeA6().
  Margins(0.5, 0.5, 0.5, 0.5).
  Send()
 if err != nil {
  log.Fatal(err)
 }
 defer resp.Body.Close()

 f, _ := os.Create("out.pdf")
 io.Copy(f, resp.Body)
 f.Close()
}

Full Examples

Github: https://github.com/nativebpm/gotenberg