pdfrender

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

README

go-tex/pdfrender

ci Go Reference

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.

Why a separate module

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.

Use

import (
	"github.com/go-tex/engine"
	"github.com/go-tex/pdfrender"
)

func init() { engine.RasterizePDF = pdfrender.Rasterize } // \includegraphics{fig.pdf} now renders

Or rasterise directly:

img, err := pdfrender.Rasterize(pdfBytes, 200) // first page at 200 DPI → image.Image
img, err  = pdfrender.RasterizePage(pdfBytes, 2, 300)

License

BSD-3-Clause — see LICENSE. Copyright the go-tex/pdfrender authors.

Documentation

Overview

Package pdfrender rasterises a PDF page to an image in pure Go (CGO=0). It is a thin wrapper over the reference renderer github.com/ajroetker/pdf/render, shaped to plug straight into go-tex/engine's RasterizePDF seam:

engine.RasterizePDF = pdfrender.Rasterize

so \includegraphics of a vector .pdf figure typesets as a real raster. The engine core stays free of this (heavy) renderer; a consumer that wants PDF figures — the CLI, loom — opts in with the line above, while the browser/wasm build leaves the seam nil and shows a placeholder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rasterize

func Rasterize(pdf []byte, dpi float64) (image.Image, error)

Rasterize renders the first page of a PDF document to an image at the given DPI. It matches the signature of go-tex/engine's RasterizePDF hook.

func RasterizePage

func RasterizePage(pdf []byte, page int, dpi float64) (image.Image, error)

RasterizePage renders a specific 1-based page of a PDF document at the given DPI.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL