[librsvg: 3/4] Fix bug when page size is different from final canvas size
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 3/4] Fix bug when page size is different from final canvas size
- Date: Tue, 12 Oct 2021 18:48:22 +0000 (UTC)
commit 03d4acd4497a1ad02e2ddfdd2696268809e17da5
Author: Michael Howell <michael notriddle com>
Date: Fri Oct 8 15:44:56 2021 -0700
Fix bug when page size is different from final canvas size
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/600>
src/bin/rsvg-convert.rs | 8 ++++----
tests/src/cmdline/rsvg_convert.rs | 30 ++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index d073bd19..d3667b9f 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -560,7 +560,7 @@ impl Converter {
match s {
#[cfg(system_deps_have_cairo_pdf)]
Surface::Pdf(pdf, size) => {
- pdf.set_size(final_size.w, final_size.h).map_err(|e| {
+ pdf.set_size(page_size.w, page_size.h).map_err(|e| {
error!(
"Error setting PDF page #{} size {}: {}",
page_idx + 1,
@@ -568,12 +568,12 @@ impl Converter {
e
)
})?;
- *size = final_size;
+ *size = page_size;
}
#[cfg(system_deps_have_cairo_ps)]
Surface::Ps(ps, size) => {
- ps.set_size(final_size.w, final_size.h);
- *size = final_size;
+ ps.set_size(page_size.w, page_size.h);
+ *size = page_size;
}
_ => {}
}
diff --git a/tests/src/cmdline/rsvg_convert.rs b/tests/src/cmdline/rsvg_convert.rs
index dde03c58..78c7c625 100644
--- a/tests/src/cmdline/rsvg_convert.rs
+++ b/tests/src/cmdline/rsvg_convert.rs
@@ -295,6 +295,36 @@ fn multiple_input_files_create_multi_page_pdf_output() {
);
}
+#[cfg(system_deps_have_cairo_pdf)]
+#[test]
+fn multiple_input_files_create_multi_page_pdf_output_fixed_size() {
+ let one = Path::new("tests/fixtures/dimensions/521-with-viewbox.svg");
+ let two = Path::new("tests/fixtures/dimensions/sub-rect-no-unit.svg");
+ let three = Path::new("tests/fixtures/api/example.svg");
+ RsvgConvert::new()
+ .arg("--format=pdf")
+ .arg("--page-width=8.5in")
+ .arg("--page-height=11in")
+ .arg("--width=7.5in")
+ .arg("--height=10in")
+ .arg("--left=0.5in")
+ .arg("--top=0.5in")
+ .arg("--keep-aspect-ratio")
+ .arg(one)
+ .arg(two)
+ .arg(three)
+ .assert()
+ .success()
+ .stdout(
+ file::is_pdf()
+ .with_page_count(3)
+ // https://www.wolframalpha.com/input/?i=convert+11+inches+to+desktop+publishing+points
+ .and(file::is_pdf().with_page_size(0, 612.0, 792.0))
+ .and(file::is_pdf().with_page_size(1, 612.0, 792.0))
+ .and(file::is_pdf().with_page_size(2, 612.0, 792.0)),
+ );
+}
+
#[cfg(system_deps_have_cairo_pdf)]
#[test]
fn pdf_has_link() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]