Overview
PdfBackend renders a Scene to PDF bytes. This backend requires the pdf feature flag and uses svg2pdf to convert SVG scenes to vector PDF.
Usage
Constructor
new
Creates a new PDF backend.
PdfBackend
default
Alias for new().
Methods
render_scene
Renders a Scene to PDF bytes.
The scene to render
Result<Vec<u8>, String>
Ok(bytes)- PDF file data ready to writeErr(msg)- Error message if rendering failed
Implementation
The PDF backend:- Renders the scene to SVG using
SvgBackend - Loads system fonts into an
svg2pdffont database - Parses the SVG with
usvg - Converts to PDF with default conversion and page options
- Returns PDF bytes
Output Format
The PDF output:- Is a vector format (scales without quality loss)
- Embeds fonts from the system
- Uses default page size based on SVG dimensions
- Preserves all SVG elements (paths, text, gradients)
Convenience Function
For one-shot rendering, use:Source
src/backend/pdf.rs