Documentation
¶
Overview ¶
Package svg provides pure-Go SVG rasterisation helpers for PDF embedding.
Index ¶
Constants ¶
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 ¶
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 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.