diff --git a/crates/automation/src/dispatch.rs b/crates/automation/src/dispatch.rs index f3c51d22e0..ab4d6310d5 100644 --- a/crates/automation/src/dispatch.rs +++ b/crates/automation/src/dispatch.rs @@ -719,6 +719,7 @@ impl Automation { "doc_hidden_info" => self.doc_hidden_info(&a)?, "printers" => self.printers()?, "printer_options" => self.printer_options(&a)?, + "printer_papers" => self.printer_papers(&a)?, "link_list" => self.link_list(&a)?, "link_open" => self.link_open(&a)?, "link_add" => self.link_add(&a)?, diff --git a/crates/automation/src/printing.rs b/crates/automation/src/printing.rs index 9a1c1a6b7c..919e8d958a 100644 --- a/crates/automation/src/printing.rs +++ b/crates/automation/src/printing.rs @@ -37,31 +37,67 @@ fn bad(m: impl Into) -> ToolError { ToolError::InvalidArgs(m.into()) } -/// `doc_print`'s `paper`, by its name or a short form ("Letter", "ARCH D"), as its `PAPERS` -/// index and size; US Letter when none is given. -fn paper_named(name: Option<&str>) -> Result<(usize, (f64, f64))> { - let mut papers = PAPERS.iter().enumerate(); - let found = match name { - None => papers.next(), - Some(p) => papers.find(|(_, (n, _))| { - n.eq_ignore_ascii_case(p) +/// Parse explicit custom dimensions like "300x500", "300 x 500", "300x500 pt". +fn parse_custom_dimensions(s: &str) -> Option<(f64, f64)> { + let s = s.trim().trim_end_matches("pt").trim_end_matches("points").trim(); + let (w_str, h_str) = s.split_once(['x', 'X', '*'])?; + let w: f64 = w_str.trim().parse().ok()?; + let h: f64 = h_str.trim().parse().ok()?; + if w.is_finite() && h.is_finite() && w >= 72.0 && h >= 72.0 && w <= 14400.0 && h <= 14400.0 { Some((w, h)) } else { None } +} + +/// `doc_print`'s `paper`, by its name, short form, driver-detected paper name, or custom dimensions. +/// Returns `(matching_papers_index, (width, height))`. +fn resolve_paper(name: Option<&str>, printer: Option<&str>) -> Result<(Option, (f64, f64))> { + if let Some(p) = name { + // 1. Match standard PAPERS presets. + for (index, (n, size)) in PAPERS.iter().enumerate() { + if n.eq_ignore_ascii_case(p) || n.replace("US ", "").eq_ignore_ascii_case(p) - || n.split(" (").next().is_some_and(|name| name.eq_ignore_ascii_case(p)) - }), - }; - found.map(|(index, (_, size))| (index, *size)).ok_or_else(|| { - bad(format!( - "unknown paper {:?}; choose one of {}", - name.unwrap_or_default(), + || n.split(" (").next().is_some_and(|label| label.eq_ignore_ascii_case(p)) + { + return Ok((Some(index), *size)); + } + } + // 2. Match detected driver papers for the given printer. + if let Some(printer_name) = printer { + let driver_papers = spool::printer_papers(printer_name); + if let Some((_, size)) = driver_papers.iter().find(|(n, _)| n.eq_ignore_ascii_case(p)) { + return Ok((print::matching_paper(*size), *size)); + } + } + // 3. Match detected driver papers across any known printer. + for pr in spool::printers() { + let driver_papers = spool::printer_papers(&pr.name); + if let Some((_, size)) = driver_papers.iter().find(|(n, _)| n.eq_ignore_ascii_case(p)) { + return Ok((print::matching_paper(*size), *size)); + } + } + // 4. Match custom dimensions ("x"). + if let Some(size) = parse_custom_dimensions(p) { + return Ok((print::matching_paper(size), size)); + } + return Err(bad(format!( + "unknown paper {p:?}; choose one of {}, a paper from printer_papers, or dimensions \"x\"", PAPERS.iter().map(|(name, _)| *name).collect::>().join(", ") - )) - }) + ))); + } + + // When paper is omitted and a printer is given, use the printer's configured default paper if readable. + if let Some(printer_name) = printer + && let Some((_, size)) = spool::printer_default_paper(printer_name) + { + return Ok((print::matching_paper(size), size)); + } + + // Default fallback: US Letter. + Ok((Some(0), PAPERS[0].1)) } /// The spooler job for `doc_print` to `printer`. It feeds the paper the PDF was laid out on /// (`PAPERS[paper]`, as `media` after the driver's `options`) rather than the queue's default /// paper, which a job naming none got (A4 under Letter sheets on the queue in #3752). -fn spool_job(a: &Args, printer: &str, title: String, duplex: Option, paper: usize) -> Result { +fn spool_job(a: &Args, printer: &str, title: String, duplex: Option, paper: Option) -> Result { let options = match a.get("options") { None => Vec::new(), Some(Value::Object(m)) => m @@ -81,7 +117,7 @@ fn spool_job(a: &Args, printer: &str, title: String, duplex: Option Result { + let printer = a.str("printer")?; + let resolved = if printer == "default" { + spool::printers().into_iter().find(|p| p.default).map(|p| p.name).unwrap_or_else(|| printer.to_string()) + } else { + printer.to_string() + }; + let (papers, default_paper) = spool::printer_paper_info(&resolved); + let list: Vec = papers.into_iter().map(|(name, (width, height))| json!({ "name": name, "width": width, "height": height })).collect(); + let default_val = default_paper.map(|(name, (width, height))| json!({ "name": name, "width": width, "height": height })); + Ok(json!({ "printer": printer, "count": list.len(), "papers": list, "default": default_val })) + } + /// `doc_print`: lay the document out with the Print dialog's options, then save the /// print-ready PDF to `path` or send it to `printer` with the chosen paper. pub(crate) fn doc_print(&mut self, a: &Args) -> Result { @@ -188,7 +239,15 @@ impl Automation { "form-fields-only" => Content::FormFieldsOnly, c => return Err(bad(format!("unknown comments_forms {c:?}"))), }; - let (paper_index, paper) = paper_named(a.opt_str("paper")?)?; + let printer_arg = a.opt_str("printer")?; + let resolved_printer = printer_arg.map(|p| { + if p == "default" { + spool::printers().into_iter().find(|pr| pr.default).map(|pr| pr.name).unwrap_or_else(|| p.to_string()) + } else { + p.to_string() + } + }); + let (paper_index, paper) = resolve_paper(a.opt_str("paper")?, resolved_printer.as_deref())?; // Print as image (Acrobat's Advanced Print Setup): pictures at `dpi`, grey when // `grayscale` is also asked for. let raster = if a.opt_bool("as_image")?.unwrap_or(false) { @@ -212,7 +271,8 @@ impl Automation { out["path"] = json!(path.to_string_lossy()); } (None, Some(printer)) => { - let job = spool_job(a, printer, self.doc(a)?.name.clone(), duplex, paper_index)?; + let actual_printer = resolved_printer.as_deref().unwrap_or(printer); + let job = spool_job(a, actual_printer, self.doc(a)?.name.clone(), duplex, paper_index)?; out["job"] = json!(spool::submit(&bytes, &job).map_err(|e| failed(e.to_string()))?); } _ => return Err(bad("pass either path (save the print-ready PDF) or printer (a name from printers, or \"default\")")), @@ -256,7 +316,7 @@ mod tests { #[test] fn printing_to_a_printer_feeds_the_laid_out_paper() { let job = |args: Value, paper_name: Option<&str>| { - let (index, _) = paper_named(paper_name).unwrap(); + let (index, _) = resolve_paper(paper_name, None).unwrap(); spool_job(&Args(&args), "Office", "a.pdf".into(), None, index).unwrap() }; let media = |m: &str| ("media".to_string(), m.to_string()); @@ -266,14 +326,14 @@ mod tests { assert_eq!((letter.printer.as_deref(), letter.title.as_str()), (Some("Office"), "a.pdf")); // Every paper, by its full name, goes out as its own media name. for (i, (name, size)) in PAPERS.iter().enumerate() { - assert_eq!(paper_named(Some(name)).ok(), Some((i, *size)), "{name}"); + assert_eq!(resolve_paper(Some(name), None).ok(), Some((Some(i), *size)), "{name}"); assert_eq!(job(json!({}), Some(name)).options, print::media_option(i).into_iter().collect::>(), "{name}"); } // Short forms find the same paper. assert_eq!(job(json!({}), Some("letter")).options, [media("Letter")]); assert_eq!(job(json!({}), Some("ARCH D")).options, [media("na_arch-d_24x36in")]); - assert!(matches!(paper_named(Some("Quarto")), Err(ToolError::InvalidArgs(m)) if m.contains("US Letter"))); - assert_eq!(spool_job(&Args(&json!({})), "default", String::new(), None, 0).ok().map(|j| j.printer), Some(None)); - assert!(spool_job(&Args(&json!({ "options": { "InputSlot": 3 } })), "Office", String::new(), None, 0).is_err()); + assert!(matches!(resolve_paper(Some("Quarto"), None), Err(ToolError::InvalidArgs(m)) if m.contains("US Letter"))); + assert_eq!(spool_job(&Args(&json!({})), "default", String::new(), None, Some(0)).ok().map(|j| j.printer), Some(None)); + assert!(spool_job(&Args(&json!({ "options": { "InputSlot": 3 } })), "Office", String::new(), None, Some(0)).is_err()); } } diff --git a/crates/automation/src/tools.rs b/crates/automation/src/tools.rs index 4672e49886..140dbba833 100644 --- a/crates/automation/src/tools.rs +++ b/crates/automation/src/tools.rs @@ -591,10 +591,17 @@ pub fn tools() -> Vec { t("printer_options", "List printer options", "A printer driver's own job options (CUPS: from its PPD), such as the paper tray, paper type or finishing: key, label, group, default and choices. Pass chosen values to doc_print as options. Empty on Windows, where the driver's preferences window holds them.") .ro() .with(schema(json!({ "printer": { "type": "string" } }), &["printer"])), + t( + "printer_papers", + "List printer paper sizes", + "The media sizes (names and dimensions in points) and default paper supported by a printer driver. Pass printer: a name from printers, or \"default\".", + ) + .ro() + .with(schema(json!({ "printer": { "type": "string" } }), &["printer"])), t( "doc_print", "Print", - "Print with Acrobat's Print dialog options, or save the print-ready PDF. pages: a range such as \"1-3, 6, 9-\" (page labels allowed; default all); subset odd/even (by page number, as Acrobat counts them: pages 2, 7-10 with even prints 2, 8 and 10, not every second page of the range); reverse. layout: fit (default), actual, shrink, custom (scale %), multiple (per_sheet 2/4/6/9/16, order, border, auto_rotate; cut-stack order arranges single-sided sheets for cutting into piles and stacking left to right, top to bottom, keeping sheet order within each pile; duplex must be off), booklet (booklet_subset both/front/back, binding left/right; a booklet sets two-sided itself, as Acrobat does: both flips on the short edge, front or back prints one-sided), poster (scale %, overlap pt, cut_marks). orientation auto/portrait/landscape; comments_forms document / document-and-markups (default) / document-and-stamps / form-fields-only; paper Letter/Legal/Tabloid, ARCH A/B/C/D/E1/E, ANSI C/D/E, A0/A1/A2/A3/A4/A5/A6, or US #10 Envelope (short names or full preset labels); use layout actual for 100% in the print-ready PDF; printer drivers may still substitute paper or scale. Then path (save) or printer (a name or \"default\") with copies, collate, duplex off/long-edge/short-edge, grayscale, and options (driver options from printer_options, CUPS).", + "Print with Acrobat's Print dialog options, or save the print-ready PDF. pages: a range such as \"1-3, 6, 9-\" (page labels allowed; default all); subset odd/even (by page number, as Acrobat counts them: pages 2, 7-10 with even prints 2, 8 and 10, not every second page of the range); reverse. layout: fit (default), actual, shrink, custom (scale %), multiple (per_sheet 2/4/6/9/16, order, border, auto_rotate; cut-stack order arranges single-sided sheets for cutting into piles and stacking left to right, top to bottom, keeping sheet order within each pile; duplex must be off), booklet (booklet_subset both/front/back, binding left/right; a booklet sets two-sided itself, as Acrobat does: both flips on the short edge, front or back prints one-sided), poster (scale %, overlap pt, cut_marks). orientation auto/portrait/landscape; comments_forms document / document-and-markups (default) / document-and-stamps / form-fields-only; paper Letter/Legal/Tabloid, ARCH A/B/C/D/E1/E, ANSI C/D/E, A0/A1/A2/A3/A4/A5/A6, US #10 Envelope, a driver paper name from printer_papers, or dimensions \"x\"; when printer is given and paper is omitted, uses the printer's default paper if available; use layout actual for 100% in the print-ready PDF; printer drivers may still substitute paper or scale. Then path (save) or printer (a name or \"default\") with copies, collate, duplex off/long-edge/short-edge, grayscale, and options (driver options from printer_options, CUPS).", ) .with(schema( json!({ diff --git a/crates/automation/tests/it/automation.rs b/crates/automation/tests/it/automation.rs index 13f9af4371..cba9e1387a 100644 --- a/crates/automation/tests/it/automation.rs +++ b/crates/automation/tests/it/automation.rs @@ -4916,6 +4916,25 @@ fn printing_through_tools() { assert!(matches!(a.call("doc_print", &json!({ "doc": doc, "pages": "99", "path": "x.pdf" })), Err(ToolError::InvalidArgs(_)))); } +#[test] +fn printer_papers_through_tools() { + let dir = workdir("printer-papers"); + let mut a = auto(&dir); + let none = ok(&mut a, "printer_papers", json!({ "printer": "No_Such_Queue_PdfCraft" })); + assert_eq!((none["count"].as_u64(), none["papers"].as_array().map(Vec::len)), (Some(0), Some(0))); + assert!(none["default"].is_null()); + assert!(matches!(a.call("printer_papers", &json!({})), Err(ToolError::InvalidArgs(_)))); + + let doc = ok(&mut a, "doc_open", json!({ "path": "a.pdf" }))["doc"].as_u64().unwrap(); + let r = ok(&mut a, "doc_print", json!({ "doc": doc, "pages": "1", "paper": "300x500", "path": "custom-paper.pdf" })); + assert_eq!(r["sheets"].as_u64(), Some(1)); + let opened = ok(&mut a, "doc_open", json!({ "path": "custom-paper.pdf" }))["doc"].as_u64().unwrap(); + let info = ok(&mut a, "doc_info", json!({ "doc": opened })); + let page = &info["pages"][0]; + assert!((page["width"].as_f64().unwrap() - 300.0).abs() <= 1.0); + assert!((page["height"].as_f64().unwrap() - 500.0).abs() <= 1.0); +} + #[test] fn adding_content_through_tools() { let dir = workdir("content"); diff --git a/crates/print/Cargo.toml b/crates/print/Cargo.toml index 69db783571..0043ee6113 100644 --- a/crates/print/Cargo.toml +++ b/crates/print/Cargo.toml @@ -16,7 +16,7 @@ pdfcraft-model = { workspace = true } thiserror = { workspace = true } [target.'cfg(windows)'.dependencies] -winprint = { version = "0.2.1", git = "https://github.com/storytold/winprint.rs", rev = "5f80b9baf6b58937c401656634e42d33f00ddf49" } +winprint = { version = "0.2.1", git = "https://github.com/storytold/winprint.rs", rev = "5f80b9baf6b58937c401656634e42d33f00ddf49", default-features = false } [dev-dependencies] pdfcraft-render = { workspace = true } diff --git a/crates/print/src/spool.rs b/crates/print/src/spool.rs index 3689a317a9..a8b7ffcd32 100644 --- a/crates/print/src/spool.rs +++ b/crates/print/src/spool.rs @@ -279,8 +279,11 @@ pub fn printer_paper_info(printer: &str) -> (Vec, Option) { (papers, default_paper) } -/// Shows the printer driver's Print Settings / DocumentProperties dialog (Windows). -/// If the user clicks OK, returns the updated paper size. +/// Shows the printer driver's Page Setup / DocumentProperties dialog (Windows). +/// +/// Returns the paper size and orientation selected by the user. Other per-job driver +/// settings (such as tray or quality) are not captured; general driver settings should +/// be configured through [`open_printer_preferences`] (Properties…). pub fn show_printer_properties(printer: &str, parent: Option) -> Result, crate::PrintError> { #[cfg(windows)] { diff --git a/crates/ui-egui/src/workflows/print_ui.rs b/crates/ui-egui/src/workflows/print_ui.rs index c42b889b11..ec6cf891c1 100644 --- a/crates/ui-egui/src/workflows/print_ui.rs +++ b/crates/ui-egui/src/workflows/print_ui.rs @@ -515,6 +515,9 @@ impl PdfCraftApp { /// a preset path returns `true` once the save picker is showing; the file is written on a /// later frame, when the user has chosen where. pub fn print_now(&mut self) -> bool { + if still_looking(&self.print_draft) || self.print_draft.papers_loading() { + return false; + } // What's typed in a form field is part of what's printed (#166). if !self.commit_form_typing() { return false; diff --git a/crates/ui-egui/src/workflows/print_ui/body.rs b/crates/ui-egui/src/workflows/print_ui/body.rs index f53e06ae5b..1d28d254a9 100644 --- a/crates/ui-egui/src/workflows/print_ui/body.rs +++ b/crates/ui-egui/src/workflows/print_ui/body.rs @@ -210,8 +210,12 @@ pub(crate) fn body( let paper_name = d.paper_name().to_string(); let before = d.paper; let mut paper_clicked = false; + let detecting = d.papers_loading(); ui.horizontal(|ui| { craft_ui::ComboBox::from_id_salt("paper").selected_text(tl!(&paper_name)).width(180.0).show_ui(ui, |ui| { + if detecting { + ui.add_enabled(false, egui::Label::new(tl!("Detecting paper…"))); + } for (i, (name, _)) in d.papers.iter().enumerate() { if ui.selectable_value(&mut d.paper, i, tl!(name)).clicked() { paper_clicked = true; @@ -220,8 +224,11 @@ pub(crate) fn body( }) .response .labelled_by(paper_label.id); + if detecting { + ui.label(egui::RichText::new(tl!("Detecting…")).small().color(t.text_muted)); + } let page_setup_tip = if spool::HAS_PRINTER_PREFERENCES { - tl!("Opens the printer driver's page setup: paper size, orientation and source.") + tl!("Selects paper size and orientation from the printer driver. For paper tray, print quality or other driver defaults, use Properties…") } else { tl!("Page setup dialog is not available on this system.") }; @@ -574,8 +581,13 @@ pub(crate) fn body( let (mut go, mut cancel) = (false, false); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { let looking = still_looking(d); + let waiting_paper = d.papers_loading(); let label = if d.printer.is_some() || looking { tl!("Print") } else { tl!("Save as PDF") }; - if ui.add_enabled_ui(settings.is_ok() && !sheets.is_empty() && !looking, |ui| widgets::pill_button(ui, label, true)).inner.clicked() { + if ui + .add_enabled_ui(settings.is_ok() && !sheets.is_empty() && !looking && !waiting_paper, |ui| widgets::pill_button(ui, label, true)) + .inner + .clicked() + { go = true; } if widgets::pill_button(ui, tl!("Cancel"), false).clicked() { diff --git a/crates/ui-egui/src/workflows/print_ui/draft.rs b/crates/ui-egui/src/workflows/print_ui/draft.rs index c40f482add..560e8ae0ff 100644 --- a/crates/ui-egui/src/workflows/print_ui/draft.rs +++ b/crates/ui-egui/src/workflows/print_ui/draft.rs @@ -172,6 +172,15 @@ impl PrintDraft { }) } + /// Whether automatic paper detection for the selected printer is in progress and unresolved. + /// + /// When true, the user has not explicitly chosen or overridden the paper, and the selected + /// printer's media sizes and default paper are still being read in the background off the GUI thread. + pub fn papers_loading(&self) -> bool { + let Some(p) = self.printer.as_deref() else { return false }; + !self.paper_overridden && (self.papers_loading.as_deref() == Some(p) || self.read_papers_for.as_deref() == Some(p)) + } + /// Reset an automatically selected custom paper to a standard preset on printer change. /// /// If the currently selected paper does not match any standard preset and `paper_overridden` is false, diff --git a/crates/ui-egui/tests/it/print.rs b/crates/ui-egui/tests/it/print.rs index 21f66ef05a..bd87a384da 100644 --- a/crates/ui-egui/tests/it/print.rs +++ b/crates/ui-egui/tests/it/print.rs @@ -1078,6 +1078,95 @@ fn printer_list_refresh_resets_unoverridden_custom_paper_when_default_printer_ch assert_eq!(h.state().print_draft.paper_name(), "US Letter"); } +#[test] +fn print_button_waits_for_automatic_paper_detection_before_submission() { + use pdfcraft_engine::print::spool; + use std::sync::{Arc, Mutex, mpsc}; + + let mut h = harness(); + let (release_tx, release_rx) = mpsc::channel(); + let (started_tx, started_rx) = mpsc::channel(); + let release_rx = Arc::new(Mutex::new(release_rx)); + let started_tx = Arc::new(Mutex::new(started_tx)); + + h.state_mut().printer_source = + Some(Arc::new(|| vec![spool::Printer { name: "Label 4x6 Printer".into(), default: true, two_sided: None, description: String::new() }])); + let rx_clone = Arc::clone(&release_rx); + let tx_clone = Arc::clone(&started_tx); + h.state_mut().printer_papers_source = Some(Arc::new(move |_| { + let _ = tx_clone.lock().unwrap().send(()); + let _ = rx_clone.lock().unwrap().recv(); + vec![("Shipping Label 4x6".into(), (288.0, 432.0))] + })); + h.state_mut().default_paper_source = Some(Arc::new(|_| Some(("Shipping Label 4x6".into(), (288.0, 432.0))))); + + assert!(h.state_mut().execute("print.dialog")); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + while h.state().print_draft.printers_loading && std::time::Instant::now() < deadline { + h.run_steps(1); + std::thread::sleep(std::time::Duration::from_millis(5)); + } + // Wait until background paper worker has reached the channel gate + let _ = started_rx.recv_timeout(std::time::Duration::from_secs(5)); + + // While background read is pending and paper is not manually overridden: + assert!(h.state().print_draft.papers_loading(), "papers_loading must be true while automatic detection is pending"); + assert!(!h.state_mut().print_now(), "print_now must be refused while paper detection is pending"); + + // Overriding paper manually resolves the pending state and enables submission immediately + h.state_mut().print_draft.paper_overridden = true; + assert!(!h.state().print_draft.papers_loading(), "papers_loading becomes false once paper is overridden"); + assert!(h.state_mut().print_now(), "print_now succeeds when user has chosen a paper"); + + // Unblock the worker so the thread finishes cleanly + let _ = release_tx.send(()); +} + +#[test] +fn gated_paper_detection_enables_print_after_worker_finishes() { + use pdfcraft_engine::print::spool; + use std::sync::{Arc, Mutex, mpsc}; + + let mut h = harness(); + let (release_tx, release_rx) = mpsc::channel(); + let (started_tx, started_rx) = mpsc::channel(); + let release_rx = Arc::new(Mutex::new(release_rx)); + let started_tx = Arc::new(Mutex::new(started_tx)); + + h.state_mut().printer_source = + Some(Arc::new(|| vec![spool::Printer { name: "Label 4x6 Printer".into(), default: true, two_sided: None, description: String::new() }])); + let rx_clone = Arc::clone(&release_rx); + let tx_clone = Arc::clone(&started_tx); + h.state_mut().printer_papers_source = Some(Arc::new(move |_| { + let _ = tx_clone.lock().unwrap().send(()); + let _ = rx_clone.lock().unwrap().recv(); + vec![("Shipping Label 4x6".into(), (288.0, 432.0))] + })); + h.state_mut().default_paper_source = Some(Arc::new(|_| Some(("Shipping Label 4x6".into(), (288.0, 432.0))))); + + assert!(h.state_mut().execute("print.dialog")); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + while h.state().print_draft.printers_loading && std::time::Instant::now() < deadline { + h.run_steps(1); + std::thread::sleep(std::time::Duration::from_millis(5)); + } + let _ = started_rx.recv_timeout(std::time::Duration::from_secs(5)); + + assert!(h.state().print_draft.papers_loading()); + assert!(!h.state_mut().print_now()); + + // Release the worker + let _ = release_tx.send(()); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10); + while h.state().print_draft.papers_loading() && std::time::Instant::now() < deadline { + h.run_steps(1); + std::thread::sleep(std::time::Duration::from_millis(5)); + } + assert!(!h.state().print_draft.papers_loading()); + assert_eq!(h.state().print_draft.paper_size(), (288.0, 432.0)); + assert!(h.state_mut().print_now()); +} + #[test] fn restored_paper_keeps_preview_and_saved_sheet_dimensions() { use pdfcraft_engine::print::{self, PAPERS}; diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml index 8b7ac909a0..9eb44dd9e2 100644 --- a/parity/acrobat-features.toml +++ b/parity/acrobat-features.toml @@ -8280,11 +8280,15 @@ title = "Page setup" area = "L" tier = "P1" milestone = "M10" -status = "planned" -commands = [] -tools = [] -evidence = [] -notes = "" +status = "shipped" +commands = ["print.dialog"] +tools = ["printer_papers"] +evidence = [ + "crates/ui-egui/tests/it/print.rs::printer_papers_and_properties_selection", + "crates/automation/tests/it/automation.rs::printer_papers_through_tools", + "crates/print/src/tests.rs::printer_papers_and_default_paper_api", +] +notes = "The Print dialog's Page Setup button opens the driver's page setup to choose paper size and orientation. printer_papers enumerates driver-reported papers and default paper headlessly." [[feature]] id = "print.print-ready-pdf"