PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Merge PR #3633: fix(print): retain existing appearances without Subtype
aiongg6a74968144b1
diff --cc ROADMAP.mdindex c0faf5aa7,bed4df890..248f3480b--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -172,9 -174,7 +174,10 @@@ Ranked; detail and the full milestone t## Progress log+- **2026-10-20 (M6, calculation order page):** Prepare a form ▸ Calculation order, a page of its own, lists the calculated fields in the order they calculate with their formulas and values, moved with Up/Down arrows (as Acrobat's Set Field Calculation Order), Alt+↑/↓ or by dragging. A card says what is wrong with the order and holds Fix order; a loop has a card of its own that opens one of its formulas. On the page, each calculated field shows its step, and arrows show what the field in focus reads and what reads it. Estimates unchanged.+- **2026-10-20 (M6, calculation order):** The order a form's fields calculate in (`/CO`) is read, checked, fixed and set headlessly with `form_calculation_order`: it says which fields read one calculated later (they show stale values), which read each other in a loop, and which the PDF's order leaves out; Fix order moves only what must move, in one undo step, and the form recalculates. Editing a formula no longer moves its field to the end of the order, and a field the order lists twice calculates once. Estimates unchanged.+- **2026-10-19 (M6, renames keep formulas):** Renaming a field renames it in every calculation that reads it, in the same undo step: `AFSimple_Calculate` field lists, simplified field notation (the comment and the JavaScript after it) and `getField` calls naming it in one string literal; the rest of each script is kept as written. A sum used to drop the renamed field, notation read it as 0 and a script kept a stale value. Field Properties says how many formulas changed and `form_set_props` lists them as `formulas_updated`. Names built at run time and other events' scripts are not rewritten. Estimates unchanged.+ - **2026-10-20 (M10, #3532 partial):** Vector printing retains existing widget artwork when its appearance lacks Subtype. A print-owned copy adds Form dispatch metadata. The source stream and all explicit subtypes stay unchanged. Synthetic source/output raster checks cover resources, selected/shared appearances, placement, flags and content modes. Appearance regeneration and physical printer validation remain outside this fix. Estimates unchanged.- **2026-10-19 (M14, #3373):** The main menu and its long submenus scroll in short windows, keeping their commands reachable. Estimates unchanged.diff --cc crates/print/src/tests.rsindex 47eab0162,4e1c3fa74..ddfb888b5--- a/crates/print/src/tests.rs+++ b/crates/print/src/tests.rs@@@ -781,93 -745,4 +781,95 @@@ fn imposed_pages_preserve_large_user_un}}+/// `output_within` (#1818): the bounded wait every platform's `lpoptions` call goes through.+#[cfg(not(target_arch = "wasm32"))]+mod bounded_commands {+ const MODE: &str = "PDFCRAFT_COMMAND_TEST_MODE";++ /// The child process stands in for a command: it answers, or it never does.+ #[test]+ fn stand_in_for_a_command() {+ match std::env::var(MODE).as_deref() {+ Ok("answer") => println!("hello from the command"),+ Ok("hang") => std::thread::sleep(std::time::Duration::from_secs(60)),+ // Holds the output pipe it inherited for a while, as a daemon a command starts can.+ Ok("linger") => std::thread::sleep(LINGER),+ // Starts a lingering process on its own output, then exits or hangs itself.+ Ok(mode @ ("orphan-exit" | "orphan-hang")) => {+ let _ = command("linger").spawn();+ println!("started");+ if mode == "orphan-hang" {+ std::thread::sleep(std::time::Duration::from_secs(60));+ }+ }+ _ => {}+ }+ }++ const LINGER: std::time::Duration = std::time::Duration::from_secs(8);++ fn command(mode: &str) -> std::process::Command {+ let mut c = std::process::Command::new(std::env::current_exe().unwrap());+ c.args(["--exact", "tests::bounded_commands::stand_in_for_a_command", "--nocapture", "--"]).env(MODE, mode);+ c+ }++ #[test]+ fn a_command_that_answers_gives_its_output() {+ let out = crate::spool::output_within(&mut command("answer"), std::time::Duration::from_secs(60)).unwrap();+ assert!(String::from_utf8_lossy(&out).contains("hello from the command"));+ }++ #[test]+ fn a_command_that_never_answers_is_stopped_at_the_deadline() {+ let started = std::time::Instant::now();+ let err = crate::spool::output_within(&mut command("hang"), std::time::Duration::from_millis(500)).unwrap_err();+ assert_eq!(err.kind(), std::io::ErrorKind::TimedOut);+ assert!(started.elapsed() < std::time::Duration::from_secs(20), "stopped soon after the deadline, not when the command gives up");+ }++ /// A process the command started keeps the output pipe open after the command has exited,+ /// or after it was killed at the deadline: the wait still ends at the deadline (#2108+ /// review), not when that process lets go of the pipe.+ #[test]+ fn a_process_left_holding_the_output_does_not_extend_the_wait() {+ for mode in ["orphan-exit", "orphan-hang"] {+ let started = std::time::Instant::now();+ let err = crate::spool::output_within(&mut command(mode), std::time::Duration::from_millis(1500)).unwrap_err();+ assert_eq!(err.kind(), std::io::ErrorKind::TimedOut, "{mode}");+ assert!(started.elapsed() < LINGER / 2, "{mode}: returned after {:?}, when the lingering process let go", started.elapsed());+ }+ }+}++#[test]+fn driver_options_take_the_ppds_own_names_in_the_ui_language() {+ use crate::spool::{PrinterOption, localize, parse_ppd, ppd_text};+ // Latin-1 elsewhere (the é), UTF-8 in the localization lines, as drivers ship them.+ let mut ppd = b"*cupsLanguages: \"bg pt_BR\"\n*OpenGroup: Finishing/Finishing Options\n*OpenUI *KMDuplex/Print Type: PickOne\n*DefaultKMDuplex: Single\n*KMDuplex Single/1-Sided: \"\"\n*KMDuplex Double/2-Sided: \"\"\n*CloseUI: *KMDuplex\n*OpenUI *Staple/Staple: PickOne\n*DefaultStaple: None\n*Staple None/None: \"\"\n*CloseUI: *Staple\n*CloseGroup: Finishing\n*fr.Translation KMDuplex/Type d'impression r".to_vec();+ ppd.push(0xE9);+ ppd.extend_from_slice("el: \"\"\n*bg.Translation Finishing/Довършителни операции: \"\"\n*bg.Translation KMDuplex/Тип печат: \"\"\n*bg.KMDuplex Single/Едностранен: \"\"\n*bg.KMDuplex Double/: \"\"\n*pt_BR.Translation KMDuplex/Tipo de impressão: \"\"\n".as_bytes());+ let parsed = parse_ppd(&ppd_text(&ppd));+ let label = |o: &[PrinterOption], key: &str| o.iter().find(|o| o.key == key).map(|o| o.label.clone()).unwrap();+ let mut bg = parsed.clone();+ localize(&mut bg, &ppd, "bg");+ let duplex = bg.iter().find(|o| o.key == "KMDuplex").unwrap();+ assert_eq!((duplex.label.as_str(), duplex.group.as_str()), ("Тип печат", "Довършителни операции"));+ assert_eq!(+ duplex.choices,+ [("Single".to_string(), "Едностранен".to_string()), ("Double".to_string(), "2-Sided".to_string())],+ "an empty translation keeps the driver's name"+ );+ assert_eq!(label(&bg, "Staple"), "Staple", "untranslated options keep theirs");+ // Region-specific codes, then the language alone; languages the PPD lacks change nothing.+ let mut pt = parsed.clone();+ localize(&mut pt, &ppd, "pt-br");+ assert_eq!(label(&pt, "KMDuplex"), "Tipo de impressão");+ for lang in ["en", "de", "", "bg-"] {+ let mut other = parsed.clone();+ localize(&mut other, &ppd, lang);+ assert_eq!(other == parsed, lang != "bg-", "{lang:?}");+ }+}+++ mod appearances;diff --cc docs/roadmap.mdindex 201cc1d6c,1c8722f86..ae504008d--- a/docs/roadmap.md+++ b/docs/roadmap.md@@@ -202,9 -202,7 +204,10 @@@ M2 (renderer), M7 (content editing), M1| Date | Change | Summary ||---|---|---|+| 2026-10-20 | minor | M6: Prepare a form ▸ Calculation order: formulas and values, what is wrong and Fix order, Up/Down, Alt+↑/↓ and drag, links on the page. Estimates unchanged. |+| 2026-10-20 | minor | M6: `form_calculation_order` reads, checks, fixes and sets the calculation order; an edited formula keeps its place in `/CO`. Estimates unchanged. |+| 2026-10-19 | minor | M6: renaming a field renames it in the calculations that read it; `form_set_props` returns `formulas_updated` and Field Properties says how many changed. Estimates unchanged. |+ | 2026-10-20 | minor | M10, #3532 partial: vector printing retains existing appearances with absent Subtype; estimates unchanged. || 2026-10-18 | minor | M5, PR #1971: nested source `/Page` and `/Pages` dictionaries export as null without traversing page content or the page tree. Synthetic saved/reopened three-page regression retains unrelated metadata and aliases. FDF import semantics, copied-graph limits and estimates unchanged. || 2026-10-15 | minor | M5: budget retained FDF entries before cloning; discovery keeps lazy array owners and annotation positions, with alias/cache-eviction stress fixtures. Limits cover the copied graph; source parsing/page discovery retain existing COS/parser limits, with no total source-memory bound. FDF import semantics and estimates unchanged. || 2026-10-15 | minor | M7: Edit text caret height follows its row, with a kittest regression; estimates unchanged |