Expand description
SVG - wrapper around an XObject
to allow for more
control within the library
Fields
width: Px
Width of the rendered SVG content
height: Px
Height of the rendered SVG content
Implementations
sourceimpl Svg
impl Svg
sourcepub fn parse(svg_string: &str) -> Result<Self, SvgParseError>
pub fn parse(svg_string: &str) -> Result<Self, SvgParseError>
Internally parses the SVG string, converts it to a PDF document using the svg2pdf crate, parses the resulting PDF again (using lopdf), then extracts the SVG XObject.
I wish there was a more direct way, but handling SVG is very tricky.
sourcepub fn into_xobject(self, layer: &PdfLayerReference) -> SvgXObjectRef
pub fn into_xobject(self, layer: &PdfLayerReference) -> SvgXObjectRef
Adds the SVG to the pages /Resources, returns the name of the reference to the SVG, so that one SVG can be used more than once on a page
sourcepub fn add_to_layer(self, layer: &PdfLayerReference, transform: SvgTransform)
pub fn add_to_layer(self, layer: &PdfLayerReference, transform: SvgTransform)
Adds the image to a specific layer and consumes it.
This is due to a PDF weirdness - images are basically just “names” and you have to make sure that they are added to resources of the same page as they are used on.
You can use the “transform.dpi” parameter to specify a scaling - the default is 300dpi
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Svg
impl Send for Svg
impl Sync for Svg
impl Unpin for Svg
impl UnwindSafe for Svg
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more