fschutt / printpdf

A fully-featured PDF library for Rust, WASM-ready
https://fschutt.github.io/printpdf/
MIT License
814 stars 98 forks source link

SVG images cannot use text inside #184

Open qarmin opened 2 months ago

qarmin commented 2 months ago

Usvg dependency supports embedding text inside svg, but printpdf not

Svg used to test behavior

<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
  <text x="50" y="55" font-size="20" text-anchor="middle" fill="white">A</text>
</svg>

image

image

fschutt commented 2 days ago

Yeah, this is a pretty normal problem since PDF handles fonts / text specially. You'd have to first use a SVG library to convert the text to paths.