svg

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package svg provides pure-Go SVG rasterisation helpers for PDF embedding.

Index

Constants

View Source
const (
	DPIForRaster    = 150.0
	MaxRasterPixels = 50_000_000
)

DPIForRaster is the resolution SVGs are rasterised at, and MaxRasterPixels the largest raster the renderer will allocate.

Variables

View Source
var (
	ErrSVGHasZeroDimensions = errors.New("svg has zero dimensions")
	ErrSVGTooLarge          = htmllimits.ErrSVGTooLarge

	// ErrSVGTooComplex reports an SVG whose shapes need more rasterisation work
	// than the pixel budget allows. It wraps ErrSVGTooLarge so callers that gate
	// on the SVG limit keep treating it as a limit failure.
	ErrSVGTooComplex = fmt.Errorf("%w: rasterization budget exhausted", htmllimits.ErrSVGTooLarge)
)

Errors reported when an SVG cannot be rasterised.

Functions

func Rasterize

func Rasterize(svgBytes []byte, widthMM, heightMM float64) ([]byte, int, int, error)

Rasterize converts SVG bytes into PNG bytes at the requested mm dimensions.

func RasterizeWithLimit

func RasterizeWithLimit(svgBytes []byte, widthMM, heightMM float64, maxPixels int64) ([]byte, int, int, error)

RasterizeWithLimit converts SVG bytes into PNG bytes with a pixel cap. A maxPixels of zero or less disables both the canvas cap and the rasterisation work budget, and is only safe for trusted input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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