Pure-Go (CGO=0) rasteriser for PDF figures, shaped to plug into
go-tex/engine's RasterizePDF seam so
\includegraphics of a vector .pdf typesets as a real raster instead of a
placeholder. A thin wrapper over the reference renderer
github.com/ajroetker/pdf/render.
A pure-Go PDF renderer is a heavy dependency (pdfcpu and friends). The engine core —
and its browser/wasm build — stay free of it: the engine exposes a func seam, and
a consumer that wants PDF figures (the CLI, loom) opts in with one line.
import (
"github.com/go-tex/engine"
"github.com/go-tex/pdfrender"
)
func init() { engine.RasterizePDF = pdfrender.Rasterize } // \includegraphics{fig.pdf} now rendersOr rasterise directly:
img, err := pdfrender.Rasterize(pdfBytes, 200) // first page at 200 DPI → image.Image
img, err = pdfrender.RasterizePage(pdfBytes, 2, 300)BSD-3-Clause — see LICENSE. Copyright the go-tex/pdfrender authors.