graphitepdf-svg 0.4.0

SVG parsing and conversion for GraphitePDF.
Documentation

Overview

graphitepdf-svg parses SVG input into a typed SvgNode tree that downstream crates can inspect, size, transform, and render.


Scope

graphitepdf-svg contains:

  • SvgNode and SvgNodeKind
  • SvgProps for normalized attribute storage
  • try_parse_svg() and parse_svg() entry points
  • typed tree output rather than raw XML strings

Installation

cargo add graphitepdf-svg

API Summary

Category Items
SVG tree SvgNode, SvgNodeKind, SvgProps
Parsing try_parse_svg(), parse_svg()

Example

use graphitepdf_svg::try_parse_svg;

fn main() -> graphitepdf_svg::Result<()> {
    let svg = try_parse_svg(
        r#"<svg width=\"10\" height=\"10\"><rect x=\"0\" y=\"0\" width=\"10\" height=\"10\" fill=\"black\"/></svg>"#,
    )?;

    assert_eq!(svg.children.len(), 1);
    Ok(())
}

Design Principles

  • expose parsed SVG as typed scene data
  • keep parsing fallible and explicit
  • avoid baking in PDF emission concerns
  • make downstream sizing and rendering easier by normalizing structure early

Role In GraphitePDF

This crate is the workspace's SVG scene layer. It feeds image, math, layout, render, and kit.


License

MIT