Skip to content

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

Merge upstream main and preserve optional page-edge shadows

JMb728d06ce10a
diff --cc ATTRIBUTION.toml
index 36900e0a9,07433fc45..d6257f77b
--- a/ATTRIBUTION.toml
+++ b/ATTRIBUTION.toml
@@@ -7,7 -7,7 +7,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Greek UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "882c0de87fd784acd0d98738d5db18dff619666fcf5d65ad49af53ae02071a52"
-sha256 = "389982dcbb7f1ac29fb150c9af43f9529db6e59a091b9971f0401684847d8b53"
++sha256 = "a4b95023bc2ab99b8712acecb529959b261704400398551f3f73390de887f621"
# ATTRIBUTION.toml: one entry per asset (AGENTS.md §1). The source of truth for provenance and licences.
# ATTRIBUTION.md is generated from this file: `cargo xtask assets --write`. Checked by `cargo xtask assets` (part of `xtask ci`).
@@@ -30,7 -30,7 +30,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Simplified Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "b58781b77c3c285b63f3dc455c0d59c90bc330b2680ef40484c438ebda192d8e"
-sha256 = "d8ea23644d81476e3fd35c09780ab9b3ac8c9e28bed4e14e1cbc6493bb896d91"
++sha256 = "6427553770a182872b31963640ae25c17bef7ca7749aa6f94ba0f2fd32d9cf50"
[[asset]]
path = "crates/ui-egui/src/i18n/zh-hant.tsv"
@@@ -41,7 -41,7 +41,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Traditional Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "a649395b81c3209dd15e647154d77fa234d57a90107dbc0c5d6b268c64194719"
-sha256 = "26dd0b0d697fd40db996fc102f3c7f2320bdeb6d6af38dbdde353bd5d940baad"
++sha256 = "2c55dc2c15a19f1c718037afe2ca0ac413978776fe065a1d8c48ff8f76e28338"
[[asset]]
path = "crates/ui-egui/src/i18n/cs.tsv"
@@@ -52,7 -52,7 +52,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Czech UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "d0cbf5ae09d732d3446be4f8f68ae78a1b1c0b370c199d0045d3c8522c3ad84c"
-sha256 = "322b8cda21a2b8d157716182846619bd92bfb31263d1f8d13da7eaad365fbfd7"
++sha256 = "ce58e69fbcfd0f399d6cdd7d9fccf5ff4509e4ee47c58e6426daee7c59fd4f89"
[[asset]]
path = "crates/ui-egui/src/i18n/pt-br.tsv"
@@@ -63,7 -63,7 +63,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Brazilian Portuguese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "232e203183548507747a128f7870a1d2b85f57198ef3cb08177021b2689f13d1"
-sha256 = "21bf9c73b482eb987ddaf839b4a4aa8f9938d5aa10428e6d39beea254a95a0c0"
++sha256 = "1037bf896b4d7bfe2c1ecd2e4b488bb4c78655cc867d16cb65e714adf907b0c2"
[[asset]]
path = "crates/ui-egui/src/i18n/es.tsv"
@@@ -74,7 -74,7 +74,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Spanish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "ea80209d0192489065fd97e4e21ea537a83e371021dff0831256ffa265ba0f4d"
-sha256 = "fef35ae1771edf2e044e72aebb958bb4827ded57234207f96b6cb7a250fedb22"
++sha256 = "6ab674b38045f215dcb643aedafe6763f336a670f321b8011df5f6bb0b9238cc"
[[asset]]
path = "crates/ui-egui/src/i18n/fr.tsv"
@@@ -85,7 -85,7 +85,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "French UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "3904d5f143a6e8861c22c5adbd2d3af3b7e2ff82d0cb40b3443180255ab55ab0"
-sha256 = "d723622298b10400e9a1ba697cbebd831f5e0f7e5bbe4545b97f61e64db7535f"
++sha256 = "bbba95ed5c1bcbae086a3cbe30b05d8d0daae5a90e279d0636b33e8f7f1b85fe"
[[asset]]
path = "crates/ui-egui/src/i18n/de.tsv"
@@@ -96,7 -96,7 +96,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "German UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "ebd76484896b8931e84066acd8a4ba1c60e023cb90baffca1f0a54bd3ebc3e8f"
-sha256 = "686ab9658b7ef9dd7f3af05ce73f99f1ab2a75f8357bad6f7e987d40a8730df9"
++sha256 = "915785e53cf2844a19d2abd7120f2f1792e2555b1224f441ec3cf6985a841b40"
[[asset]]
path = "crates/ui-egui/src/i18n/te.tsv"
@@@ -107,7 -107,7 +107,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Telugu UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "0ad017eade954c43cd61e41342c733de46937177f07aa91f16aa8491d114904e"
-sha256 = "90b94038699aa74aa48ffbda3e90a2255b65d0dbf081e8ecf20c5804940fc129"
++sha256 = "1632acf0d68b8127203b0435d67659fdd8975df6a4100715e64d301892746d2f"
[[asset]]
path = "crates/ui-egui/src/i18n/it.tsv"
@@@ -118,7 -118,7 +118,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Italian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "bc96cc2e0ee2bb2bebc48eff1faf934d5873d443639b3b7d248b17d0d16b9977"
-sha256 = "5aa6475df91a3e82010aee198c2e29bb80328505bbd0240f3828e36a5d6dfdf3"
++sha256 = "2ed055bcec912a14caba6e58b2855a07c19ab7e58500151cbe5f33ef56e80c18"
[[asset]]
path = "crates/ui-egui/src/i18n/pl.tsv"
@@@ -129,7 -129,7 +129,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Polish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "5c75987e23f74c0273fd38c7af8682a5fc48aee3ceda6582b28e49ff42b4b1e1"
-sha256 = "e6d306d9bf289fac2fe8fcfa6f9d0a51b650728e45669289d391be2031076692"
++sha256 = "22a6ef932a0560b27df30bd09b8cc9ec1e463affd1c76ece9732b836155d8536"
[[asset]]
path = "crates/ui-egui/src/i18n/ru.tsv"
@@@ -140,7 -140,7 +140,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Russian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "e483d99fae3fe4fb579f3f1844903537c28d1d4acd2fcfc822f64ab77f7a4098"
-sha256 = "277f4995a87297a2fcc473df1feebdbdf3378fa460a7f85eb1a0a151cee40a2b"
++sha256 = "016d47686f8d7bad07637433465a8a94e4a55f3dd86301adaab02db98b221abe"
[[asset]]
path = "crates/ui-egui/src/i18n/hu.tsv"
@@@ -151,7 -151,7 +151,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Hungarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "e54073fd593756b00812c5bd5b951ae6e50d06d4812f988c88034f513065caef"
-sha256 = "01b32370cedce935b74925858a79ee691dc2a5560ba5eb758de2de1c243c528e"
++sha256 = "b709824ac987be697e3db542524c0bfb64546460c470898689163814ca356541"
[[asset]]
path = "crates/ui-egui/src/i18n/bg.tsv"
@@@ -162,7 -162,7 +162,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Bulgarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "da8dff590b62692c2fd67a60e2c2c32f3093ae425946772bbc705f35f9764de2"
-sha256 = "f8ae97901c61dfdc0a844a23356173211bb052b3ff54128d7edc8097c535eee9"
++sha256 = "cd50450b84a8bada1c75c3d04e4f1f5f7ea5dba9c8b5f4955d6757677bdd5799"
[[asset]]
path = "crates/ui-egui/src/i18n/kk.tsv"
@@@ -173,7 -173,7 +173,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Kazakh UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "4105b4fb3a088b34c2844edcff9e9a66f7c8dcaa6f6a45936c868dc3b24767c1"
-sha256 = "7107ba77577794395451dd85355a86ef3e033a7f240b72414b877b9b43adb19e"
++sha256 = "9277a45401d06cac680506ab5b7100093df3b7bca4bc3f1130145d387947446d"
[[asset]]
path = "crates/ui-egui/src/i18n/ja.tsv"
@@@ -184,7 -184,7 +184,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Japanese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "97a9416f8cef0248fb3bedc2fdb38b21f6e882455255a3ff1e879652188f155b"
-sha256 = "114b3d50531eb1682535c7a646e62914b0c9afaa5d5d1b9f66b94fd472e4e7b3"
++sha256 = "d9e20c4e60c4460105f6395e2ab6bb5f49c574399ded9130499e03f29559088f"
[[asset]]
path = "crates/ui-egui/src/i18n/uk.tsv"
@@@ -195,7 -195,7 +195,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Ukrainian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "17c818311e6422d4e4b49a71dcc1d784f78920b7b21b493d4e11170f7791c6e3"
-sha256 = "f56ec5f4cb7d1992041df0783f1cfd76c27d5d180c3f73c60b104e3fd02f600d"
++sha256 = "cafd5475da2d8c2613a84f7790fb5b9c421945163621468dff2b3f0b0d86c12e"
[[asset]]
path = "crates/ui-egui/src/i18n/ar.tsv"
@@@ -206,7 -206,7 +206,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Arabic UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "7f9bc12fe0514cf61675d8537623aff84829c711d5efdb68ba4b158cd2aeb13c"
-sha256 = "113fdf57e28fcff90d212fb468011bedebfb98ac100218d29b584f4de4c87912"
++sha256 = "fa4521f7ecc50ffb8e5186ad5de80f9ba4a67799f580e9cb8a84c824efd7d699"
[[asset]]
path = "crates/ui-egui/src/i18n/tr.tsv"
@@@ -217,7 -217,7 +217,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Turkish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "b666eaf326370ded831ae26a0a4e214d1e42cdf374de64f1d4244391736c47b1"
-sha256 = "2b5edfe026578ed475f07f94f1d1ed4a3dac93a745c19209589936e2d67f6ec5"
++sha256 = "a84024e205bb9b71b801de9f9d5f0b7967007c4d4da44bd7bab2ea415daa3de8"
[[asset]]
path = "crates/ui-egui/src/i18n/lt.tsv"
@@@ -228,7 -228,7 +228,7 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Lithuanian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "2b3a1b676f258c3903bf2447b93adcec7aadb53d3820902869301c0e5bf7f1ec"
-sha256 = "fe58835b0538f470b463f078e1b4cdf78a8e2632056bc61c6946071478f39a64"
++sha256 = "fc41d9d7007ec2111bde170b0581036c083b410d582fe753e156abe272d963f7"
[[asset]]
path = "assets/icons/accessibility.svg"
@@@ -3351,4 -3351,4 +3351,4 @@@ licence = "MIT OR Apache-2.0
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Slovene UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
- sha256 = "f9a381fdfea0731a6913b552ea6fb209404ab27a75abe4c817e42d379091a78e"
-sha256 = "9bbbd0d516f284b571ad6e2ed811f6bbdee283cea8483686f4aa939db38ea288"
++sha256 = "4f7f2a3b506bb5590b32ca51165d99fa9fc78f4606110f59f89d8e7667bece02"
diff --cc ROADMAP.md
index 630550c14,b4ab4ea8a..bd879c6a7
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -2,7 -2,8 +2,8 @@@
**Stage: alpha** · next: beta, ~26% (ready for real work 49% → 75%) and ~400–700 h away
- > **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (M3 #1577: optional page-edge shadows and viewport-edge fades; earlier: M13: CLI check visits each directory once through aliases and cycles; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
-> **Last reviewed:** 2026-10-13 · **Last updated:** 2026-10-13 · **Change:** minor (M3 candidate: native opens retain chosen tools through password retries and defer startup intake while preparation is pending; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
++> **Last reviewed:** 2026-10-13 · **Last updated:** 2026-10-13 · **Change:** minor (M3 #1577: optional page-edge shadows and viewport-edge fades; native-opening candidate: native opens retain chosen tools through password retries and defer startup intake while preparation is pending; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
+ > **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M13: CLI check visits each directory once through aliases and cycles; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M4: Extract and Split preserve shared Type 3 glyph resources; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M2: packed TIFF-predictor RGB rows retain their byte boundaries; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M3 #1364 candidate: consent before absolute local GoToR access; estimates unchanged); earlier: minor (M1 #1339: an unchanged incremental save of a classic cross-reference table writes a zero-length subsection; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
@@@ -148,8 -149,8 +149,10 @@@ Ranked; detail and the full milestone t
## Progress log
+- 2026-10-13 — M3, #1577: optional app-wide page-edge shadows and viewport-edge fades in the viewer and Organize grid; enabled by default, persisted and controllable through the UI channel. PDF rendering and edits are unchanged.
+
+ - **2026-10-13 (M3, native-opening candidate):** Chosen tools survive preparation, conversion and password retries; startup intake waits for pending preparation. Regression tests cover completion, cancellation and document identity. Estimates unchanged.
+ - **2026-10-12 (M10, Windows printing without PowerShell, #1107):** craft-print now prints on Windows in-process: printers from EnumPrinters/GetDefaultPrinter, jobs drawn as vectors by Windows.Data.Pdf into the XPS print API with a driver-validated PrintTicket (exact paper, orientation, no scaling), so printing works where App Control for Business or AppLocker run PowerShell in Constrained Language Mode. Portrait and landscape sheets still print as one job (turned with /Rotate); a sheet size the driver lacks is refused rather than shrunk. Pins craft-libs f03ec27 (craft-libs#28); deny.toml allows the storytold/winprint.rs fork and adds a webpki-root-certs licence exception and a RUSTSEC-2024-0370 ignore for winprint's build-dependencies. An earlier craft-print revision was checked in Windows Sandbox under enforced WDAC: printers listed, CLI and desktop jobs spooled, and no powershell.exe in the 4688 audit. The final pinned revision passed craft-libs Windows CI, including a real paused-queue job; that Sandbox run has not been repeated. Estimates unchanged.
- **2026-10-12 (M13, CLI robustness scans):** `pdfcraft-cli check` visits a directory once even when input roots overlap or directory symlinks lead back into the tree. PDFs reached through file symlinks remain accepted. Three real CLI regressions cover overlapping roots, a directory cycle and directory/file aliases. Estimates unchanged.
- **2026-10-12 (M4, Type 3 extraction fidelity):** Extract and Split preserve shared image/resource dictionaries reached through Type 3 glyphs, including nested forms, patterns and soft masks. A bounded object-graph walk protects unknown glyph content; unreadable pages/forms retain their glyph resources, and shared explicit fonts are visited once. Separate page dictionaries still prune unused images. Synthetic save/reopen regressions and an opt-in Poppler pixel oracle cover resource ownership, nested forms, cycles, limits and repeated fonts. Estimates unchanged.
- **2026-10-12 (M2, TIFF predictor rows):** Packed RGB images using TIFF horizontal differencing keep every row when samples do not fill the last byte. The renderer aligns each decoded row before moving to the next. Synthetic decoding tests cover 1/2/4-bit samples, horizontal differencing and an 8-bit control; a red/green page-render regression verifies visible output. Estimates unchanged.
diff --cc crates/ui-egui/tests/page_shadows.rs
index 9cdee3f7a,000000000..106260583
mode 100644,000000..100644
--- a/crates/ui-egui/tests/page_shadows.rs
+++ b/crates/ui-egui/tests/page_shadows.rs
@@@ -1,350 -1,0 +1,352 @@@
+//! Decorative page shadows are app preferences, never PDF edits.
+
+use egui_kittest::{Harness, kittest::Queryable};
+use pdfcraft_ui_egui::PdfCraftApp;
+
+#[test]
+fn viewer_shadows_follow_the_preference_without_moving_pages() {
+ for theme in ["light", "dark"] {
+ for layout in ["single", "two-page", "continuous", "two-up"] {
+ let mut h = harness(theme);
+ h.state_mut().set_option("layout", layout).unwrap();
+ h.run_steps(3);
+ let rectangles = h.state().views[0].visible_page_rects().to_vec();
+ let original = shadows(&h, false);
+ assert!(!original.is_empty(), "{theme} {layout}");
+ h.state_mut().set_option("show_page_edge_shadows", "false").unwrap();
+ h.run_steps(2);
+ assert!(shadows(&h, false).is_empty(), "{theme} {layout}");
+ assert_eq!(h.state().views[0].visible_page_rects(), rectangles);
+ h.state_mut().set_option("zoom", "125").unwrap();
+ h.state_mut().set_option("page", "2").unwrap();
+ h.run_steps(3);
+ assert!(shadows(&h, false).is_empty());
+ h.state_mut().set_option("show_page_edge_shadows", "true").unwrap();
+ h.run_steps(2);
+ assert!(!shadows(&h, false).is_empty());
+ }
+ }
+}
+
+#[test]
+fn viewport_fades_follow_the_preference_and_keep_other_scroll_areas_styled() {
+ for theme in ["light", "dark"] {
+ for organize in [false, true] {
+ let mut h = harness(theme);
+ if organize {
+ h.state_mut().set_option("organize", "on").unwrap();
+ // Make the three-page grid overflow vertically.
+ h.state_mut().set_option("grid-zoom", "300").unwrap();
+ }
+ h.run_steps(4);
+ let original_style = h.ctx.global_style().spacing.scroll.fade;
+ assert!(original_style.strength > 0.0);
+ assert!(!viewport_fades(&h).is_empty(), "bottom fade at start: {theme}, organize={organize}");
+ scroll_down(&mut h, 100.0);
+ let original = viewport_fades(&h);
+ let viewport = h.state().views[0].viewport_rect();
+ assert!(original.iter().any(|r| (r.top() - viewport.top()).abs() < 2.0), "top fade: {original:?}");
+ assert!(original.iter().any(|r| (r.bottom() - viewport.bottom()).abs() < 2.0), "bottom fade: {original:?}");
+ let pages = h.state().views[0].visible_page_rects().to_vec();
+ h.state_mut().set_option("show_page_edge_shadows", "false").unwrap();
+ h.run_steps(2);
+ assert!(viewport_fades(&h).is_empty(), "viewport fades remain: {theme}, organize={organize}");
+ assert_eq!(h.state().views[0].visible_page_rects(), pages);
+ assert_eq!(h.ctx.global_style().spacing.scroll.fade, original_style);
+ h.state_mut().set_option("show_page_edge_shadows", "true").unwrap();
+ h.run_steps(2);
+ assert_eq!(viewport_fades(&h), original);
+ scroll_down(&mut h, 100_000.0);
+ let at_end = viewport_fades(&h);
+ assert!(at_end.iter().any(|r| (r.top() - viewport.top()).abs() < 2.0));
+ assert!(!at_end.iter().any(|r| (r.bottom() - viewport.bottom()).abs() < 2.0), "no bottom fade at the end");
+ }
+ }
+}
+
+#[test]
+fn horizontal_viewport_fades_also_follow_the_preference() {
+ let mut h = harness("dark");
+ h.state_mut().set_option("zoom", "400").unwrap();
+ h.run_steps(4);
+ let viewport = h.state().views[0].viewport_rect();
+ let horizontal: Vec<_> = viewport_fades(&h).into_iter().filter(|r| r.width() <= 21.0).collect();
+ assert!(horizontal.iter().any(|r| (r.left() - viewport.left()).abs() < 2.0), "left fade: {horizontal:?}");
+ assert!(horizontal.iter().any(|r| (r.right() - viewport.right()).abs() < 2.0), "right fade: {horizontal:?}");
+ let pages = h.state().views[0].visible_page_rects().to_vec();
+ h.state_mut().set_option("show_page_edge_shadows", "false").unwrap();
+ h.run_steps(2);
+ assert!(viewport_fades(&h).is_empty());
+ assert_eq!(h.state().views[0].visible_page_rects(), pages);
+}
+
+fn scroll_down(h: &mut Harness<'static, PdfCraftApp>, points: f32) {
+ h.hover_at(h.state().views[0].viewport_rect().center());
+ h.run_steps(1);
+ h.event(egui::Event::MouseWheel {
+ unit: egui::MouseWheelUnit::Point,
+ delta: egui::vec2(0.0, -points),
+ phase: egui::TouchPhase::Move,
+ modifiers: egui::Modifiers::NONE,
+ });
+ h.run_steps(12);
+}
+
+/// Inspect the actual egui painter output: untextured four-vertex gradients
+/// with a transparent edge, spanning one dimension of the document viewport.
+fn viewport_fades(h: &Harness<'static, PdfCraftApp>) -> Vec<egui::Rect> {
+ let viewport = h.state().views[0].viewport_rect();
+ h.output()
+ .shapes
+ .iter()
+ .filter_map(|s| {
+ let egui::Shape::Mesh(mesh) = &s.shape else { return None };
+ if mesh.texture_id != egui::TextureId::default() || mesh.vertices.len() != 4 || mesh.indices.len() != 6 {
+ return None;
+ }
+ let rect = mesh.calc_bounds();
+ let transparent = mesh.vertices.iter().filter(|v| v.color == egui::Color32::TRANSPARENT).count();
+ (transparent == 2
+ && (((rect.width() - viewport.width()).abs() < 2.0 && rect.height() <= 21.0)
+ || ((rect.height() - viewport.height()).abs() < 2.0 && rect.width() <= 21.0))
+ && rect.intersects(viewport))
+ .then_some(rect)
+ })
+ .collect()
+}
+
+#[test]
+fn organize_shadows_follow_the_preference() {
+ for theme in ["light", "dark"] {
+ let mut h = harness(theme);
+ h.state_mut().set_option("organize", "on").unwrap();
+ h.run_steps(3);
+ let original = shadows(&h, true);
+ assert_eq!(original.len(), 3);
+ h.state_mut().set_option("show_page_edge_shadows", "false").unwrap();
+ h.run_steps(2);
+ assert!(shadows(&h, true).is_empty());
+ h.state_mut().set_option("show_page_edge_shadows", "true").unwrap();
+ h.run_steps(2);
+ assert_eq!(shadows(&h, true), original);
+ }
+}
+
+#[test]
+fn checkbox_and_multiple_documents_do_not_edit_pdf_state() {
+ let mut h = harness("light");
+ h.state_mut().open_bytes("second.pdf", None, pdf()).unwrap();
+ let ids: Vec<_> = h.state().views.iter().map(|v| v.id).collect();
+ h.state_mut().session.apply(ids[0], pdfcraft_engine::Edit::SetInfo { key: "Title".into(), value: "Keep existing edits".into() }).unwrap();
+ assert!(h.state().session.get(ids[0]).unwrap().dirty);
+ assert!(h.state().session.get(ids[0]).unwrap().can_undo().is_some());
+ let saved: Vec<_> = ids.iter().map(|id| h.state_mut().session.save_bytes(*id).unwrap()).collect();
+ let before: Vec<_> = h
+ .state()
+ .views
+ .iter()
+ .map(|v| {
+ let d = h.state().session.get(v.id).unwrap();
+ (
+ d.bytes.clone(),
+ d.dirty,
+ d.can_undo().map(str::to_owned),
+ d.can_redo().map(str::to_owned),
+ d.info.pages.iter().map(|p| (p.width, p.height, p.rotation)).collect::<Vec<_>>(),
+ )
+ })
+ .collect();
+ h.state_mut().set_option("dialog", "preferences").unwrap();
+ h.run_steps(3);
+ let checkbox = h.get_by_label("Show Page Edge Shadows");
+ checkbox.click();
+ h.run_steps(2);
+ assert_eq!(serde_json::from_str::<serde_json::Value>(&h.state().persist()).unwrap()["show_page_edge_shadows"], false);
+ h.get_by_label("Show Page Edge Shadows").focus();
+ h.key_press(egui::Key::Space);
+ h.run_steps(2);
+ assert_eq!(serde_json::from_str::<serde_json::Value>(&h.state().persist()).unwrap()["show_page_edge_shadows"], true);
+ let dialog_shadow = h.ctx.global_style().visuals.window_shadow;
+ assert_ne!(dialog_shadow, egui::Shadow::NONE);
+ h.state_mut().set_option("show_page_edge_shadows", "false").unwrap();
+ h.run_steps(2);
+ assert_eq!(h.ctx.global_style().visuals.window_shadow, dialog_shadow);
+ h.state_mut().set_option("dialog", "none").unwrap();
+ for tab in [0, 1] {
+ h.state_mut().active = Some(tab);
+ h.run_steps(2);
+ assert!(shadows(&h, false).is_empty());
+ let d = h.state().session.get(h.state().views[tab].id).unwrap();
+ assert_eq!(
+ (&d.bytes, d.dirty, d.can_undo(), d.can_redo()),
+ (&before[tab].0, before[tab].1, before[tab].2.as_deref(), before[tab].3.as_deref())
+ );
+ assert_eq!(d.info.pages.iter().map(|p| (p.width, p.height, p.rotation)).collect::<Vec<_>>(), before[tab].4);
+ }
+ for (id, bytes) in ids.iter().zip(&saved) {
+ assert_eq!(h.state_mut().session.save_bytes(*id).unwrap(), *bytes);
+ }
+ h.state_mut().open_bytes("new.pdf", None, pdf()).unwrap();
+ h.run_steps(2);
+ assert!(shadows(&h, false).is_empty());
+}
+
+#[test]
+fn rendered_page_content_is_identical_with_and_without_decoration() {
+ let mut h = harness("dark");
+ h.state_mut().set_option("panel", "pages").unwrap();
+ h.state_mut().set_option("zoom", "175").unwrap();
+ h.run_steps(3);
+ scroll_down(&mut h, 20.0);
+ for _ in 0..400 {
+ h.run_steps(2);
+ if !h.state().render_pending() {
+ break;
+ }
+ std::thread::sleep(std::time::Duration::from_millis(5));
+ }
+ assert!(!h.state().render_pending(), "the actual PDF raster must be ready");
+ let rect = h.state().views[0].page_screen_rect(0).unwrap();
+ let fades = viewport_fades(&h);
+ assert_eq!(fades.iter().filter(|r| r.height() <= 21.0).count(), 2, "the screenshot comparison must contain both vertical fades");
+ let enabled = h.render().unwrap();
+ h.state_mut().set_option("show_page_edge_shadows", "false").unwrap();
+ h.run_steps(2);
+ let disabled = h.render().unwrap();
+ assert_eq!(h.state().views[0].page_screen_rect(0), Some(rect));
+ let viewport = h.state().views[0].viewport_rect();
+ assert!(viewport_fades(&h).is_empty());
+ // Only the painter's actual decorative fade strips may change over the page.
+ // All remaining artwork, annotation and form pixels must be identical.
+ for (_, page) in h.state().views[0].visible_page_rects() {
+ let visible = page.intersect(viewport).shrink(2.0);
+ if !visible.is_positive() {
+ continue;
+ }
+ for y in visible.top().ceil() as u32..visible.bottom().floor() as u32 {
+ for x in visible.left().ceil() as u32..visible.right().floor() as u32 {
+ if !fades.iter().any(|fade| fade.expand(1.0).contains(egui::pos2(x as f32, y as f32))) {
+ assert_eq!(enabled.get_pixel(x, y), disabled.get_pixel(x, y), "page content at {x},{y}");
+ }
+ }
+ }
+ }
+ // The top overlaps the first page's blue artwork; the bottom overlaps the
+ // blank second page. Sample clear of the unchanged scrollbar at the edge.
+ let x = rect.intersect(viewport).center().x as u32;
+ for (y, expected) in [(viewport.top() + 8.0, [204, 230, 255, 255]), (viewport.bottom() - 10.0, [255, 255, 255, 255])] {
+ assert_eq!(disabled.get_pixel(x, y as u32).0, expected, "unobscured PDF at y={y}");
+ assert_ne!(enabled.get_pixel(x, y as u32).0, expected, "fade overlays the PDF at y={y}");
+ }
+ // The Pages sidebar, including its thumbnails and selection borders, is unaffected.
+ for y in 0..enabled.height() {
+ for x in (0..viewport.left().floor() as u32).chain(viewport.right().ceil() as u32..enabled.width()) {
+ assert_eq!(enabled.get_pixel(x, y), disabled.get_pixel(x, y), "sidebar at {x},{y}");
+ }
+ }
+ assert_ne!(enabled.as_raw(), disabled.as_raw(), "the decoration really changes the image");
+ if let Ok(directory) = std::env::var("PDFCRAFT_SHADOW_SCREENSHOTS") {
+ enabled.save(format!("{directory}/page-shadows-enabled.png")).unwrap();
+ disabled.save(format!("{directory}/page-shadows-disabled.png")).unwrap();
+ }
+}
+
+fn harness(theme: &str) -> Harness<'static, PdfCraftApp> {
+ let theme = theme.to_string();
+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_| {
+ let mut app = PdfCraftApp::new();
++ // Save comparisons must not depend on crossing a /ModDate second boundary.
++ app.session = app.session.with_clock(|| 1_700_000_000);
+ app.set_option("language", "en").unwrap();
+ app.set_option("theme", &theme).unwrap();
+ app.open_bytes("pages.pdf", None, pdf()).unwrap();
+ app.set_option("zoom", "100").unwrap();
+ app
+ });
+ h.run_steps(3);
+ h
+}
+
+fn shadows(h: &Harness<'static, PdfCraftApp>, grid: bool) -> Vec<egui::Rect> {
+ let color = pdfcraft_ui_egui::theme::Tokens::for_kind(h.state().theme).page_shadow;
+ fn collect(shape: &egui::Shape, color: egui::Color32, grid: bool, out: &mut Vec<egui::Rect>) {
+ match shape {
+ egui::Shape::Vec(shapes) => {
+ for s in shapes {
+ collect(s, color, grid, out);
+ }
+ }
+ egui::Shape::Rect(r)
+ if r.fill == color
+ && r.rect.width() > 20.0
+ && r.rect.height() > 20.0
+ && if grid {
+ r.blur_width == 0.0 && r.corner_radius == egui::CornerRadius::same(1)
+ } else {
+ r.blur_width == 14.0 && r.corner_radius == egui::CornerRadius::ZERO
+ } =>
+ {
+ out.push(r.rect)
+ }
+ _ => {}
+ }
+ }
+ let mut out = Vec::new();
+ for s in &h.output().shapes {
+ collect(&s.shape, color, grid, &mut out);
+ }
+ out
+}
+
+/// Synthetic pages include colored artwork, an annotation and a form field.
+fn pdf() -> Vec<u8> {
+ let objects = [
+ "<< /Type /Catalog /Pages 2 0 R /AcroForm << /Fields [7 0 R] >> >>".to_string(),
+ "<< /Type /Pages /Kids [3 0 R 4 0 R 5 0 R] /Count 3 /MediaBox [0 0 300 400] >>".to_string(),
+ "<< /Type /Page /Parent 2 0 R /Contents 8 0 R /Annots [6 0 R 7 0 R] >>".to_string(),
+ "<< /Type /Page /Parent 2 0 R >>".to_string(),
+ "<< /Type /Page /Parent 2 0 R >>".to_string(),
+ "<< /Type /Annot /Subtype /Text /Rect [20 20 40 40] /Contents (Note) >>".to_string(),
+ "<< /Type /Annot /Subtype /Widget /FT /Tx /T (field) /V (value) /Rect [50 50 100 70] /P 3 0 R >>".to_string(),
+ {
+ let body = "0.8 0.9 1 rg 0 0 300 400 re f 0.3 g 10 10 280 8 re f";
+ format!("<< /Length {} >>\nstream\n{body}\nendstream", body.len())
+ },
+ ];
+ let mut bytes = b"%PDF-1.7\n".to_vec();
+ let mut offsets = Vec::new();
+ for (i, object) in objects.iter().enumerate() {
+ offsets.push(bytes.len());
+ bytes.extend_from_slice(format!("{} 0 obj\n{object}\nendobj\n", i + 1).as_bytes());
+ }
+ let xref = bytes.len();
+ bytes.extend_from_slice(format!("xref\n0 {}\n0000000000 65535 f \n", objects.len() + 1).as_bytes());
+ for offset in offsets {
+ bytes.extend_from_slice(format!("{offset:010} 00000 n \n").as_bytes());
+ }
+ bytes.extend_from_slice(format!("trailer\n<< /Size {} /Root 1 0 R >>\nstartxref\n{xref}\n%%EOF\n", objects.len() + 1).as_bytes());
+ bytes
+}
+
+#[test]
+fn page_shadow_preference_round_trips_and_ignores_invalid_settings() {
+ let mut app = PdfCraftApp::new();
+ let enabled = |app: &PdfCraftApp| serde_json::from_str::<serde_json::Value>(&app.persist()).unwrap()["show_page_edge_shadows"].clone();
+ assert_eq!(enabled(&app), true);
+ app.restore("{}");
+ assert_eq!(enabled(&app), true);
+ for value in [false, true] {
+ app.set_option("show_page_edge_shadows", if value { "true" } else { "false" }).unwrap();
+ let mut restored = PdfCraftApp::new();
+ restored.restore(&app.persist());
+ assert_eq!(enabled(&restored), value);
+ }
+ for invalid in ["null", "0", "\"false\"", "[]", "{}"] {
+ app.restore(&format!("{{\"show_page_edge_shadows\":{invalid}}}"));
+ assert_eq!(enabled(&app), true);
+ }
+ app.restore("not json");
+ assert_eq!(enabled(&app), true);
+ assert!(app.set_option("show_page_edge_shadows", "maybe").is_err());
+ assert_eq!(enabled(&app), true);
+}
diff --cc docs/roadmap.md
index 354689402,fabb5e603..f7d65bf65
--- a/docs/roadmap.md
+++ b/docs/roadmap.md
@@@ -1,6 -1,7 +1,7 @@@
# PdfCraft roadmap: milestones and what's next
- > **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (M3 #1577: optional page-edge shadows and viewport-edge fades; earlier: M13: CLI check visits each directory once through aliases and cycles; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
-> **Last reviewed:** 2026-10-13 · **Last updated:** 2026-10-13 · **Change:** minor (M3 candidate: native opens retain chosen tools through password retries and defer startup intake while preparation is pending; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
++> **Last reviewed:** 2026-10-13 · **Last updated:** 2026-10-13 · **Change:** minor (M3 #1577: optional page-edge shadows and viewport-edge fades; native-opening candidate: native opens retain chosen tools through password retries and defer startup intake while preparation is pending; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
+ > **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M13: CLI check visits each directory once through aliases and cycles; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M4: Extract and Split preserve shared Type 3 glyph resources; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M2: packed TIFF-predictor RGB rows retain their byte boundaries; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (M3 #1364 candidate: consent before absolute local GoToR access; estimates unchanged); earlier: minor (M1 #1339: unchanged incremental saves of a classic cross-reference table write a zero-length subsection; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
@@@ -90,7 -91,7 +91,7 @@@ total matches the parity estimate
| M1 | COS: filters, crypt, parser, xref, writer | 120–200 | 80% | 20–40 | Done:<br>- filters and crypt: every standard-security revision R2–R6 (RC4, AES-128/256), SASLprep, permissions, creating encryption;<br>- cos: parse and repair (including invalid xref object-number ranges), decoded-stream limits including unfiltered data, decrypt on load, re-encrypt on save, incremental and full writing.<br>Corpus: open/edit/save passes on 958 files, and all 7 password-protected files open.<br>Full saves now pack objects into compressed object streams. An unchanged incremental save of a classic table writes a zero-length cross-reference subsection instead of a section with no subsections (#1339). Fuzzing runs nightly (`xtask fuzz`). Missing: ≥ 250 tests, own image codecs |
| M2 | Model, render, text | 200–350 | 15% | 130–230 | hayro bootstrap renderer (vendored patches); inspector predictor scratch is bounded by available input, and JPX sample rescaling handles 1–32 bits safely. Text extraction reaches word-F1 0.98 against pdftotext. Short same-line redraws split before placement rather than interleaving. Missing: model crate, fonts, DisplayList, renderer independent of hayro. Inspector page-label traversal and output are resource-bounded, with physical-number fallback warnings. Packed TIFF-predictor RGB rows retain later rows in decoding and rendering. |
| M2 | Model, render, text | 200–350 | 15% | 130–230 | hayro bootstrap renderer (vendored patches); inspector predictor scratch is bounded by available input, and JPX sample rescaling handles 1–32 bits safely. Text extraction reaches word-F1 0.98 against pdftotext. Short same-line redraws split before placement rather than interleaving. Missing: model crate, fonts, DisplayList, renderer independent of hayro. Inspector page-label traversal and output are resource-bounded, with physical-number fallback warnings |
- | M3 | Viewer app (native + web) | 80–150 | 90% | 10–20 | Acrobat-style shell, find, select, panels, tiles, web build, UI control channel for agents (opt-in). Missing: 60 fps test on a 500-page document, snapshot tests of every panel<br>Done since: fit visible, document title in the window; Linux middle-button scrolling; shared three-state theme preferences in the toolbar, View menu and control channel; numeric Linux portal events and idle wakeups completing #881, with native appearance inheritance retained (#446); late browser startup downloads preserve the current document and Save target (#171). #1364 candidate: absolute local GoToR links ask before target access; headless callers explicitly opt in. Preferences ▸ Appearance can hide decorative page-edge shadows and viewport-edge fades in the viewer and Organize grid (#1577); enabled by default, persisted app-wide and exposed through UI control. |
-| M3 | Viewer app (native + web) | 80–150 | 90% | 10–20 | Acrobat-style shell, find, select, panels, tiles, web build, UI control channel for agents (opt-in). Missing: 60 fps test on a 500-page document, snapshot tests of every panel<br>Done since: fit visible, document title in the window; Linux middle-button scrolling; shared three-state theme preferences in the toolbar, View menu and control channel; numeric Linux portal events and idle wakeups completing #881, with native appearance inheritance retained (#446); late browser startup downloads preserve the current document and Save target (#171). #1364 candidate: absolute local GoToR links ask before target access; headless callers explicitly opt in. Native-opening candidate: chosen tools survive preparation and password retries; startup intake waits for pending preparation. |
++| M3 | Viewer app (native + web) | 80–150 | 90% | 10–20 | Acrobat-style shell, find, select, panels, tiles, web build, UI control channel for agents (opt-in). Missing: 60 fps test on a 500-page document, snapshot tests of every panel<br>Done since: fit visible, document title in the window; Linux middle-button scrolling; shared three-state theme preferences in the toolbar, View menu and control channel; numeric Linux portal events and idle wakeups completing #881, with native appearance inheritance retained (#446); late browser startup downloads preserve the current document and Save target (#171). #1364 candidate: absolute local GoToR links ask before target access; headless callers explicitly opt in. Native-opening candidate: chosen tools survive preparation and password retries; startup intake waits for pending preparation. Preferences ▸ Appearance can hide decorative page-edge shadows and viewport-edge fades in the viewer and Organize grid (#1577); enabled by default, persisted app-wide and exposed through UI control. |
| M2 | Model, render, text | 200–350 | 15% | 130–230 | hayro bootstrap renderer (vendored patches); inspector predictor scratch is bounded by available input, and JPX sample rescaling handles 1–32 bits safely. Text extraction reaches word-F1 0.98 against pdftotext. Short same-line redraws split before placement rather than interleaving. A custom text match that ends on a reconstructed separator stops before the next glyph (#1315). Missing: model crate, fonts, DisplayList, renderer independent of hayro. Inspector page-label traversal and output are resource-bounded, with physical-number fallback warnings |
| M2 | Model, render, text | 200–350 | 15% | 130–230 | hayro bootstrap renderer (vendored patches); Lab Bradford adaptation uses LMS white-point ratios, covered by independent neutral/chromatic and direct/Indexed render oracles; inspector predictor scratch is bounded by available input, and JPX sample rescaling handles 1–32 bits safely. Text extraction reaches word-F1 0.98 against pdftotext. Short same-line redraws split before placement rather than interleaving. Missing: model crate, fonts, DisplayList, renderer independent of hayro. Inspector page-label traversal and output are resource-bounded, with physical-number fallback warnings |
| M3 | Viewer app (native + web) | 80–150 | 90% | 10–20 | Acrobat-style shell, find, select, panels, tiles, web build, UI control channel for agents (opt-in). Missing: 60 fps test on a 500-page document, snapshot tests of every panel<br>Done since: fit visible, document title in the window; Linux middle-button scrolling; shared three-state theme preferences in the toolbar, View menu and control channel; numeric Linux portal events and idle wakeups completing #881, with native appearance inheritance retained (#446); late browser startup downloads preserve the current document and Save target (#171). |