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.

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.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.