We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images with an alpha channel are not rendered by printpdf. See for example this modification of the images.rs example:
printpdf
images.rs
extern crate printpdf; use printpdf::*; use image::{GenericImage, GenericImageView}; use std::fs::File; use std::io::BufWriter; fn main() { let (doc, page1, layer1) = PdfDocument::new("printpdf graphics test", Mm(20.0), Mm(20.0), "Layer 1"); let (mut page, mut layer) = (page1, layer1); let image_constructors: &[(&str, fn(u32, u32) -> image::DynamicImage)] = &[ ("bgr8", image::DynamicImage::new_bgr8), ("bgra8", image::DynamicImage::new_bgra8), ("luma16", image::DynamicImage::new_luma16), ("luma8", image::DynamicImage::new_luma8), ("luma_a16", image::DynamicImage::new_luma_a16), ("luma_a8", image::DynamicImage::new_luma_a8), ("rgb16", image::DynamicImage::new_rgb16), ("rgb8", image::DynamicImage::new_rgb8), ("rgba16", image::DynamicImage::new_rgba16), ("rgba8", image::DynamicImage::new_rgba8), ]; let red = image::Rgba([255, 0, 0, 255]); let font = doc.add_builtin_font(BuiltinFont::Helvetica).unwrap(); for (i, (label, image_constructor)) in image_constructors.into_iter().enumerate() { if i > 0 { let (new_page, new_layer) = doc.add_page(Mm(20.0), Mm(20.0), "Layer 1"); page = new_page; layer = new_layer; } let mut image = image_constructor(100, 100); for x in 0..image.width() { for y in 0..image.height() { image.put_pixel(x, y, red); } } let image = Image::from_dynamic_image(&image); let current_layer = doc.get_page(page).get_layer(layer); current_layer.use_text(*label, 12.0, Mm(0.0), Mm(10.0), &font); image.add_to_layer(current_layer, None, None, None, None, None, None); } doc.save(&mut BufWriter::new(File::create("test_image.pdf").unwrap())).unwrap(); }
Only the images without an alpha channel are present in the generated PDF file: test_image.pdf
(This was initially reported against genpdf-rs).
The text was updated successfully, but these errors were encountered:
Sorry, I just realized that this is a duplicate of #84.
Sorry, something went wrong.
No branches or pull requests
Images with an alpha channel are not rendered by
printpdf
. See for example this modification of theimages.rs
example:Only the images without an alpha channel are present in the generated PDF file:
test_image.pdf
(This was initially reported against genpdf-rs).
The text was updated successfully, but these errors were encountered: