Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

Merge PR #2748: M10: a booklet decides two-sided itself, as Acrobat does (#2707)

aiongg8ff6c8af31f4
diff --cc crates/automation/src/printing.rs
index 74e732814,6c122feb6..9a1c1a6b7
--- a/crates/automation/src/printing.rs
+++ b/crates/automation/src/printing.rs
@@@ -22,7 -22,16 +22,17 @@@ fn duplex(value: &str, cut_stack: bool
})
}
+ /// [`duplex`] for a job laid out as `layout`: the name is checked either way, and a booklet
+ /// decides two-sided itself (#2707), as the Print dialog does (`print::booklet_duplex`).
+ fn job_duplex(value: &str, layout: &Layout) -> Result<Option<spool::Duplex>> {
+ let chosen = duplex(value, matches!(layout, Layout::Multiple { order: PageOrder::CutStack, .. }))?;
+ Ok(match layout {
+ Layout::Booklet { subset, .. } => Some(print::booklet_duplex(*subset)),
+ _ => chosen,
+ })
+ }
+
+/// An invalid-arguments error saying `m`.
fn bad(m: impl Into<String>) -> ToolError {
ToolError::InvalidArgs(m.into())
}