Skip to content

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

Merge PR #2584: M10: Two-sided starts at Printer default, so the printer's own duplex applies (#2422)

aionggd9d3a8279f6a
diff --cc crates/ui-egui/src/print_ui.rs
index 186d8edc4,ad9b4d2f9..deb31ce04
--- a/crates/ui-egui/src/print_ui.rs
+++ b/crates/ui-egui/src/print_ui.rs
@@@ -146,29 -144,9 +147,29 @@@ impl Default for PrintDraft
}
impl PrintDraft {
+ /// Choose Page Sizing & Handling. Label loads label stock and remembers the paper it
+ /// replaced; leaving Label gives that paper back, unless another one was picked meanwhile.
+ pub fn set_handling(&mut self, handling: Handling) {
+ let leaving_label = self.handling == Handling::Label && handling != Handling::Label;
+ self.handling = handling;
+ self.sheet = 0;
+ if handling == Handling::Label {
+ // A label goes on label stock.
+ if self.paper != print::LABEL_PAPER {
+ self.paper_before_label = Some(self.paper);
+ self.paper = print::LABEL_PAPER;
+ }
+ } else if leaving_label
+ && let Some(paper) = self.paper_before_label.take()
+ && self.paper == print::LABEL_PAPER
+ {
+ self.paper = paper;
+ }
+ }
+
/// The engine settings for this draft (page count and labels from the document).
pub fn settings(&self, count: usize, labels: &[String]) -> Result<print::Settings, String> {
- if self.handling == Handling::Multiple && self.order == PageOrder::CutStack && self.duplex != spool::Duplex::Off {
+ if self.cut_and_stack() && matches!(self.duplex, Some(spool::Duplex::LongEdge | spool::Duplex::ShortEdge)) {
return Err("Cut and stack needs Two-sided: Off. Print single-sided sheets.".into());
}
let range = match self.which {