pub struct Image { /* private fields */ }
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 rckive_genpdf::elements;
let image = elements::Image::from_path("examples/images/test_image.jpg")
      .expect("Failed to load test image")
      .with_alignment(rckive_genpdf::Alignment::Center) // Center the image on the page.
      .with_scale(rckive_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.

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.

Sets the expected DPI of the encoded image.

Sets the expected DPI of the encoded image and returns it.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Renders this element to the given area using the given style and font cache. Read more
Draws a frame around this element using the given line style.
Adds a padding to this element.
Sets the default style for this element and its children.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Creates a boxed element from this element.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.