Merge pull request #10904 from dotCooCoo/fix/print-bitmap-shared-grid

Print: Print as Bitmap prints at 72 ppi when the raster effects resolution is not a number
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-05 07:03:51 -08:00
commit 971bc00f8d
2 files changed
+28 -2

No files matched your search

+3 -2
View File
@@ -80,10 +80,11 @@ fn drop_guides(nodes: &mut Vec<Arc<Node>>) {
}
/// The resolution Print as Bitmap renders `doc` at with `set` (ppi): `advanced.bitmapResolution`,
/// or the document's raster effects resolution when that is 0.
/// or the document's raster effects resolution when that is 0 (72 ppi when the stored value isn't a
/// number).
fn bitmap_ppi(doc: &Document, set: &PrintSettings) -> f64 {
let asked = set.advanced.bitmap_resolution;
if asked > 0.0 { asked } else { doc.raster_effects_ppi }
if asked > 0.0 { asked } else { doc.raster_ppi() }
}
/// The pixels per document point Print as Bitmap renders `area` at so that it prints at `ppi` on
+25
View File
@@ -152,6 +152,31 @@ fn print_as_bitmap_prints_all_of_a_long_artboard() {
assert!(b.x0 <= 0.0 && b.x1 >= 9000.0, "the image covers the artboard: {b:?}");
}
/// A raster effects resolution that isn't a number prints at the resolution the document reads it
/// as (72 ppi), not as an empty page.
#[test]
fn print_as_bitmap_of_a_resolution_that_is_not_a_number_prints_at_72_ppi() {
let (s, _) = session();
let saved = s.prefs.flattener_presets.clone();
let set = settings(json!({"advanced": {"printAsBitmap": true}}));
let widths = |ppi: f64| {
let mut d = doc(&s).clone();
d.raster_effects_ppi = ppi;
let bitmap = crate::cmd::printadvanced::prepare("file.print", &d, &set, &saved, false).unwrap().unwrap();
let mut widths = vec![];
bitmap.walk(|n| {
if let NodeKind::Image(im) = &n.kind {
widths.push(im.width);
}
});
widths
};
let at_72 = widths(72.0);
assert_eq!(at_72.len(), 1, "{at_72:?}");
assert_eq!(widths(f64::NAN), at_72);
assert!(widths(144.0)[0] > at_72[0], "the resolution decides the image's size");
}
/// The images `file.print` prints with `settings`: their pixel sizes and their places on the page
/// in the print-ready PDF (read back), their pixel sizes in the PostScript file (its image
/// dictionaries, each size once), and the warnings of both.