Skip to main content

render_svg

Function render_svg 

Source
pub fn render_svg(nodes: &[Node], options: &RenderOptions) -> String
Expand description

Renders an AST to a standalone SVG document with the same layout as crate::render_html.

The image is 1 unit per printer dot: 612 × height for 80 mm paper (576 printable dots plus margins) and 420 × height for 58 mm. All receipt text is XML-escaped.

use hardless_escpos::parse;
use hardless_render::{render_svg, RenderOptions};
let svg = render_svg(&parse(b"Total: 1,250\n\x1dV\x00"), &RenderOptions::default());
assert!(svg.starts_with("<svg") && svg.contains("Total: 1,250"));
assert!(svg.contains(r#"width="612""#));