Compress embedded font streams in the PDF writer

This commit is contained in:
gloamxun committed 2026-10-19 22:15:27 +08:00
1 parent 369472e7f7
commit 4735d75c1f
80 files changed
+9119 -5

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
extern crate printpdf;
use printpdf::*;
use std::io::Cursor;
use image::bmp::BmpDecoder;
use std::fs::File;
use std::io::BufWriter;
fn main() {
let (doc, page1, layer1) = PdfDocument::new("printpdf graphics test", Mm(210.0), Mm(297.0), "Layer 1");
let current_layer = doc.get_page(page1).get_layer(layer1);
// currently, the only reliable file formats are bmp/jpeg/png
// this is an issue of the image library, not a fault of printpdf
let image_bytes = include_bytes!("../assets/img/BMP_test.bmp");
let mut reader = Cursor::new(image_bytes.as_ref());
let decoder = BmpDecoder::new(&mut reader).unwrap();
let image2 = Image::try_from(decoder).unwrap();
// layer,
image2.add_to_layer(current_layer.clone(), None, None, None, None, None, None);
doc.save(&mut BufWriter::new(File::create("test_image.pdf").unwrap())).unwrap();
}