Struct genpdf::elements::Image [−][src]
pub struct Image { /* fields omitted */ }
Expand description
An image to embed in the PDF.
Only available if the images
feature is enabled.
This struct is a wrapper around the configurations printpdf::Image
exposes.
Supported Formats
All formats supported by the image
should be supported by this crate. The BMP, JPEG and
PNG formats are well tested and known to work. Yet it is currently not possible to render
images with transparency, see printpdf
issue #98.
Note that only the GIF, JPEG, PNG, PNM, TIFF and BMP formats are enabled by default. If you
want to use other formats, you have to add the image
crate as a dependency and activate the
required feature.
Example
use std::convert::TryFrom; use genpdf::elements; let image = elements::Image::from_path("examples/images/test_image.jpg") .expect("Failed to load test image") .with_alignment(genpdf::Alignment::Center) // Center the image on the page. .with_scale(genpdf::Scale::new(0.5, 2)); // Squeeze and then stretch upwards.
Implementations
Creates a new image from an already loaded image.
Creates a new image from the given reader.
Creates a new image by reading from the given path.
Translates the image over to position.
Translates the image over to position and returns it.
Scales the image and returns it.
Sets the alignment to use for this image.
Sets the alignment to use for this image and returns it.
Sets the clockwise rotation of the image around the bottom left corner.
Sets the clockwise rotation of the image around the bottom left corner and then returns the image.
Trait Implementations
Renders this element to the given area using the given style and font cache. Read more
Draws a frame around this element.
Adds a padding to this element.
Auto Trait Implementations
impl RefUnwindSafe for Image
impl UnwindSafe for Image
Blanket Implementations
Mutably borrows from an owned value. Read more