php2pdf

SVG

$art = $doc->svg('logo.svg');                                     // native converter
$art = $doc->svg(SvgFile::fromData($svgString), new NativeConverter(fallbackFont: $sans));
$art = $doc->svg('figure.svg', new RsvgConverter());             // librsvg, when rsvg-convert is installed
$page->place($art, Box::fromMm(20, 200, 80, 60), Fit::meet());

The result is placeable like any template. The same file converts once per converter. SvgFile::size() gives the intrinsic size in points (CSS pixels at 96 dpi, so 0.75 pt each).

The native converter

Pure PHP, no extensions. It supports:

Masks (<mask>, by luminance or mask-type="alpha", with maskUnits and maskContentUnits) become soft masks; macOS Preview draws them in the wrong place in placed artwork (see canvas.md). Patterns (<pattern>, with patternUnits, patternContentUnits, viewBox, patternTransform and attributes and children inherited through href) become tiling patterns for fills and strokes. Markers (marker-start, marker-mid, marker-end and the marker shorthand, with orient including auto-start-reverse, markerUnits, viewBox and refX/refY) are drawn on paths, lines, polylines and polygons; an arc is one segment, so it takes no mid markers inside it. Filters, <textPath>, <foreignObject> and stroked text are skipped. NativeConverter::warnings() lists what the last conversion left out.

The rsvg-convert adapter

RsvgConverter runs rsvg-convert --format=pdf and imports the resulting page through the PDF importer, giving librsvg’s full fidelity including masks and filters. isAvailable() tells whether the binary can be run; pass a path to the constructor for a non-standard location.