PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Merge upstream main 9a0ec645 into pr/attachments
Osvaldo Duran6a5e6728e0b8
diff --cc ATTRIBUTION.tomlindex 0d43e20da,6c9c88a2e..5e8bc8a63--- a/ATTRIBUTION.toml+++ b/ATTRIBUTION.toml@@@ -7,7 -7,7 +7,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Greek UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "bad8d047663c82d28d2ea38ab53e92b72cc85da6272357f4b741d76b26ce546f"-sha256 = "1902f1c31698e6adfdaf65b35b1fe1628f5cd2bd0182dd3b99bcf5e21720f394"++sha256 = "99f5022c2d0bb5354701fa6b3027ea8e1084f01a8419a22f78649359f8ea6452"# 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.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Simplified Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "aaa988ba6408b91ffee7d44b5dcd66dee154d9621d49fcc28dd9ef834b8054cb"-sha256 = "2e23c41fcd5b9118cfde03b3a45aa2f988f7eeba650677b6f1f6664e543c7a59"++sha256 = "c26f12b3a0d534ed43d07b5f6e5cf4b41f85b466bd24fd77834472beb8ba1997"[[asset]]path = "crates/ui-egui/src/i18n/zh-hant.tsv"@@@ -41,7 -41,7 +41,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Traditional Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "b8c1ddddff4b1a6ce2dbeb6b0b65a281422398f47269daffaa631a292eae947f"-sha256 = "105703f2fbc07c0663308ebd6852199de12a5851a37507d7e51e477eb5e57218"++sha256 = "830fb8bebed75eec6cdd6e9796a2015670898e99170c9be636d688c476e99716"[[asset]]path = "crates/ui-egui/src/i18n/cs.tsv"@@@ -52,7 -52,7 +52,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Czech UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "d8eae3ab11c7e2153050e7468c3f6a9a7e418c2dd16951417593081d46e2fdf9"-sha256 = "7358300715a54e72a477c5888dad53f426ddf76da141a6202bec74594eb5ff0a"++sha256 = "5389557ca6d1516a977685256810efd35e351c1b06db098969647ed71e554f35"[[asset]]path = "crates/ui-egui/src/i18n/pt-br.tsv"@@@ -63,7 -63,7 +63,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Brazilian Portuguese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "922fb0aef9fe1a70269ef2536af8f5312258e4eaaba99b3932164599ad231ea5"-sha256 = "265083ea7dfa129fcae0b9e401aef8f7c84982011ba91fb2023c52705b81e639"++sha256 = "048faed903ab0d2d1f585a70ac4704f99cd5bd32de6b8b490280d2359afb6737"[[asset]]path = "crates/ui-egui/src/i18n/es.tsv"@@@ -74,7 -74,7 +74,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Spanish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "dc064e31d22139d0d169e7ed74e8cc2bb394155fde69ec90e6ec5e828c6b18d2"-sha256 = "ffcf42859cfe38ae13c6fe4219cbe6225a20b4572c202db9e82ee38bfb433799"++sha256 = "35884bea3b840490e90b805b266c6e5f3ff95f5fee2426af2320c8dd3fc85f9a"[[asset]]path = "crates/ui-egui/src/i18n/fr.tsv"@@@ -85,7 -85,7 +85,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "French UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "091f5c0b5d012262de73ef9704b01704a6e96c210c099221031ff835c1722990"-sha256 = "3f31e5c9abdb0208d48d8c68aa81437d9d1e10aeb615dedf811fefa539d93279"++sha256 = "884ec27e1bc156a9efc3e443a7fa582f67b9069e4739303ab09c8a5c35de388e"[[asset]]path = "crates/ui-egui/src/i18n/de.tsv"@@@ -96,7 -96,18 +96,18 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "German UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "b550f72c3fe3643ecc169e8e69b156b6e8ae3aceed5b0e2e0ec0543b7ceb840f"-sha256 = "815a3a672421cc3590fb1f267755316659cdb2046e30bbb3ad8b31e96f08b20a"++sha256 = "93c89bd7ee47eb5e67df51c4ba9ad85c28626427ded28377c43881cc1603887f"++ [[asset]]+ path = "crates/ui-egui/src/i18n/lo.tsv"+ title = "Lao interface translation catalog"+ author = "@bounkirdni-2025"+ source = "Contributor-original: clean-room translations of PdfCraft English UI labels, no proprietary localisation resources; 2026-10-22 page-gap labels are contributor-original AI-assisted translations from English, not separately native-reviewed"+ licence = "MIT OR Apache-2.0"+ licence_file = "LICENSE-MIT"+ kind = "translation"+ usage = "Lao UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"+ sha256 = "6bd67286795ed487eedf2ce549249c8a83286cb4273490c1349996050b540fed"[[asset]]path = "crates/ui-egui/src/i18n/te.tsv"@@@ -107,7 -118,7 +118,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Telugu UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "666dd3fb81977b5b6134e57038dbe38223b9ebd0362dd48ca945cd1b93c763ce"-sha256 = "9cd63425705fb9a3aa029ff3a5110d0877a34f9038f1d64a2102ccd6c3cb35a6"++sha256 = "8d80789e30b490423e3336a4b8423eeb861c8ead95ed7cdc2848712c5f6dce8a"[[asset]]path = "crates/ui-egui/src/i18n/it.tsv"@@@ -118,7 -129,7 +129,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Italian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "5527dc0d2cd0cbe364271ebd2e0318204a3067d2d53bf32b4baec4cb08ece17f"-sha256 = "76f138293fc12ea3584568a81f6f90a1cedfff6256e78b4f60cb21b1b66bbba4"++sha256 = "0fdd70e12441ebf1a730c648a45dd5d22071059f65e027d65fc73b35055bb693"[[asset]]path = "crates/ui-egui/src/i18n/pl.tsv"@@@ -129,7 -140,7 +140,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Polish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "14860ba5e02dbc072a20f6747e4dcfde86fba8ac1edf004879adc255c652edac"-sha256 = "7bca90240f873fcec687bea84e9ea5835f0903827501d0e73ec26b98b82e8a52"++sha256 = "50de3ee61f5fd64184a5ccba4ef0a7793beaf7bbb5483dbc791b0d4e978c4816"[[asset]]path = "crates/ui-egui/src/i18n/ru.tsv"@@@ -140,7 -151,7 +151,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Russian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "c3cc2bcedfa7c54b98a9055edd75bcdcb712987121f848fe0581514664d1349b"-sha256 = "3d539a28afcf8c2e36b7087ac23334b50bac7971e03da20a62b6e7e400763a87"++sha256 = "488e1694afe4252a6c54bf225f81c0d0ea4904cb67e64a949ec1ac41174be31e"[[asset]]path = "crates/ui-egui/src/i18n/hu.tsv"@@@ -151,7 -162,7 +162,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Hungarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "280eb530b229757dc46477246af5f73d3048d117e89ca78aaae9fddf2bc4ac38"-sha256 = "71b7e8180fc759aebad4660953ab8b55383def0572c1ace2288cd8bfeb1b82dc"++sha256 = "3f2ca7dbc614f275aa0d20b8e803e35ce44448846535bfbd675b9e441b575c17"[[asset]]path = "crates/ui-egui/src/i18n/bg.tsv"@@@ -162,7 -173,7 +173,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Bulgarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "b3a5f7008d9b62bb40af7dc54af3b602a57477f985ddbe9121188bc1c7aa9692"-sha256 = "e689fb24a8acfa7e85f0f60644f7e2da1225595e6cd6a94109fbe86082926244"++sha256 = "3fd64e50f6cb072b5d1da1ae84a5184e2a78a8cf9ad29b390af250c86eecdf8f"[[asset]]path = "crates/ui-egui/src/i18n/kk.tsv"@@@ -173,7 -184,7 +184,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Kazakh UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "9c953ef310ad75cd5597a98a34c24f259596257b72b793d540f99ac39da0ec43"-sha256 = "c601ea117ec2a3cdba606fdc9a62220fcffbd0c20c1133bacb653a979cf046a5"++sha256 = "a78857855b868baddc31a19e6ac1bf0633e0b8e6e5bd89086721ae98dc9e9716"[[asset]]path = "crates/ui-egui/src/i18n/ja.tsv"@@@ -184,7 -195,7 +195,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Japanese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "64a79ce9d575b536488932a0670be22f3cfa2cc18fb6c59516fe658c774e81d8"-sha256 = "006867b891ae2f995c7a711e55b6401db29d20ab493889c6284dc3671f9faa2d"++sha256 = "4058c4665677d645ed0bb577cd949239011dde4b36dc7611b92a33322aa6bcd4"[[asset]]path = "crates/ui-egui/src/i18n/uk.tsv"@@@ -195,7 -206,7 +206,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Ukrainian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "3b7eff378d218a9829c91bb0928ffa9d8e63c67da17cc722b1aa9a9a173bd045"-sha256 = "9e5b18a09c209525cf08ef53a242ed457cfa346295eef7facde482a75cf72f52"++sha256 = "74c122206537812ec832b5f43bd31038b4504760cdff4a506a81f28a722c948e"[[asset]]path = "crates/ui-egui/src/i18n/ar.tsv"@@@ -206,7 -217,18 +217,18 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Arabic UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "174d9f360bb33b5e0b5d5cd236898a031456058331a9c8b3f9edad854b9df795"-sha256 = "2306dbbe6a73671fd20df116adb159a7f66c85fbbd1bae5ecef5f6e882d6b7f1"++sha256 = "1661994e29cef0316c40871bb0ce7e000c2bc60ce6f3bf6edce4ac2c76b09120"++ [[asset]]+ path = "crates/ui-egui/src/i18n/ckb.tsv"+ title = "Central Kurdish (Sorani) interface translation catalog"+ author = "PdfCraft contributors"+ source = "Contributor-original: clean-room translations of PdfCraft's English UI labels, no proprietary localisation resources; 2026-10-22 page-gap labels are contributor-original AI-assisted translations from English, not separately native-reviewed"+ licence = "MIT OR Apache-2.0"+ licence_file = "LICENSE-MIT"+ kind = "translation"+ usage = "Central Kurdish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"+ sha256 = "864db8aa0a5e443c92e7e388f89349eb0f0e7beda35a0b81695d864dcec51b72"[[asset]]path = "crates/ui-egui/src/i18n/tr.tsv"@@@ -217,7 -239,7 +239,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Turkish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "b8911872e19e8ceba2137c8f0d886ddacdeef5d712d8a340f1e5b22479358e3e"-sha256 = "463a2d28bd5c5ac8df31a5b5c68400d7a61ce51237a58d9337078c973e6f9e3d"++sha256 = "1bee006dd21f281035c249a17a3bc4ccf728e8f24b3e6233945e66d12c24e73b"[[asset]]path = "crates/ui-egui/src/i18n/lt.tsv"@@@ -228,8 -250,61 +250,61 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Lithuanian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "e1ccdfc77cf3406c3f5ce81c173a9f312cf76babf29f81035435370ce837d9f1"-sha256 = "dea5076ce9c19f054812b678241931ad5e7f85dee08acf1c1e12c7ecaaa5d0f5"++sha256 = "00f8c34a068ce78ccb64656116d159c05b5723252fe871f3db7e47cd29a01db5"+ [[asset]]+ path = "crates/ui-egui/src/i18n/hi.tsv"+ title = "Hindi interface translation catalog"+ author = "PdfCraft contributors"+ source = "Contributor-original: clean-room translations of PdfCraft's English UI labels, no proprietary localisation resources; 2026-10-22 page-gap labels are contributor-original AI-assisted translations from English, not separately native-reviewed; 2026-10-22 text-field-table labels are contributor-original AI-assisted translations from English, not separately native-reviewed"+ licence = "MIT OR Apache-2.0"+ licence_file = "LICENSE-MIT"+ kind = "translation"+ usage = "Hindi UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"+ sha256 = "09d2840c02b40a6049b86c2cb68151d863913e8c91c22226f25d07496c6366aa"+ [[asset]]+ path = "crates/ui-egui/src/i18n/id.tsv"+ title = "Indonesian interface translation catalog"+ author = "PdfCraft contributors"+ source = "Contributor-original: clean-room translations of PdfCraft's English UI labels, no proprietary localisation resources; 2026-10-22 page-gap labels are contributor-original AI-assisted translations from English, not separately native-reviewed; 2026-10-22 text-field-table labels are contributor-original AI-assisted translations from English, not separately native-reviewed"+ licence = "MIT OR Apache-2.0"+ licence_file = "LICENSE-MIT"+ kind = "translation"+ usage = "Indonesian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"+ sha256 = "0dc1abdb262e4568f19ffb2233bfeb3686ae42df8a8d8bec2951351a50e6a886"+ [[asset]]+ path = "crates/ui-egui/src/i18n/ko.tsv"+ title = "Korean interface translation catalog"+ author = "PdfCraft contributors"+ source = "Contributor-original: clean-room translations of PdfCraft's English UI labels, no proprietary localisation resources; 2026-10-22 page-gap labels are contributor-original AI-assisted translations from English, not separately native-reviewed; 2026-10-22 text-field-table labels are contributor-original AI-assisted translations from English, not separately native-reviewed"+ licence = "MIT OR Apache-2.0"+ licence_file = "LICENSE-MIT"+ kind = "translation"+ usage = "Korean UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"+ sha256 = "a3e67cee4f3fff776e816523f810b2bb6353235dbdf85181c3f12896604a3339"++ [[asset]]+ path = "crates/ui-egui/src/i18n/ro.tsv"+ title = "Romanian interface translation catalog"+ author = "PdfCraft contributors"+ source = "Contributor-original: clean-room translations of PdfCraft's English UI labels and user-facing messages; AI-assisted and not yet reviewed line by line by a native Romanian speaker; 2026-10-22 page-gap labels are contributor-original AI-assisted translations from English, not separately native-reviewed; 2026-10-22 text-field-table labels are contributor-original AI-assisted translations from English, not separately native-reviewed"+ licence = "MIT OR Apache-2.0"+ licence_file = "LICENSE-MIT"+ kind = "translation"+ usage = "Romanian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"+ sha256 = "18d4beda8495d7f0b91f0dc0a52c2248d9ce6fb3f4e3de0d51f42235eaab7aa8"+++ [[asset]]+ path = "crates/ui-egui/src/i18n/fi.tsv"+ title = "Finnish interface translation catalog"+ author = "PdfCraft contributors"+ source = "Contributor-original: AI-assisted (Claude Code) clean-room translations of PdfCraft's English UI labels and user-facing messages; not yet proofread by a native Finnish speaker; 2026-10-22 page-gap labels are contributor-original AI-assisted translations from English, not separately native-reviewed; 2026-10-22 text-field-table labels are contributor-original AI-assisted translations from English, not separately native-reviewed"+ licence = "MIT OR Apache-2.0"+ licence_file = "LICENSE-MIT"+ kind = "translation"+ usage = "Finnish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"+ sha256 = "7b13e11191a3f2c0e38f1940996ae62da16e3bdb057215b2737f3a9c6a840000"[[asset]]path = "assets/icons/accessibility.svg"@@@ -3352,7 -3426,7 +3426,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Vietnamese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "00dc5f1fdef22c5b586ffe91cfe6e9d4a43cf78e0d1c754fee5ba1874fc68aac"-sha256 = "1c73f9d51b599923d704bf00c8e56b23696de16141b7a2c20aae6f60f88927a5"++sha256 = "ebb4d4fc07161120494c224fc775d373f7177c641cb7c7cbb3a613555f5eca3c"[[asset]]path = "crates/ui-egui/src/i18n/sl.tsv"@@@ -3363,7 -3437,7 +3437,7 @@@ licence = "MIT OR Apache-2.0licence_file = "LICENSE-MIT"kind = "translation"usage = "Slovene UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"- sha256 = "57563b6ae6a5a991abd580a8aa03b154caffc6667525a4bf237debeb5f91cd3e"-sha256 = "a3b8351f0da80c2d394221dbe5d62e794bb019c74c2adfc5d933d999f7d3236f"++sha256 = "305cad312a6f54732ab0cb572b10b35693c9d51ed07cf7a453632a44bc7b7961"[[asset]]diff --cc crates/engine/src/lib.rsindex b4f172d99,e20cbc596..ad64227e4--- a/crates/engine/src/lib.rs+++ b/crates/engine/src/lib.rs@@@ -42,9 -43,10 +43,10 @@@ pub mod xfapub use signature_image::{ImageSignaturePreview, SignatureImage};pub use signature_scan::{PhotoRect, ScanError, SignaturePhoto, Turn};+ pub use stamp_preview::StampPreview;pub use text_preview::TextEditPreview;-pub use pdfcraft_organize::{BoxSpec, FieldConflicts, PageBox, SplitBy, Transition, TransitionSpec, split_ranges};+pub use pdfcraft_organize::{BoxSpec, FieldConflicts, PageBox, SplitBy, Transition, TransitionSpec, mime_for_name, split_ranges};/// One file produced by a split: (1-based first page, last page, PDF bytes).pub use pdfcraft_organize::LabelStyle;diff --cc crates/organize/src/tests.rsindex fa3a78af4,7a80e38e4..fa2c33a20--- a/crates/organize/src/tests.rs+++ b/crates/organize/src/tests.rs@@@ -2790,87 -2965,81 +2965,162 @@@ fn a_chain_of_objects_too_deep_to_copy_assert!(run.is_ok(), "the copy must not overflow the stack");}+ /// The fixture after an update that adds object 20 and declares `/Size 4294967295`. No number is+ /// left above that, so [`Document::add`] fills free numbers from 12 on, the gap below object 20 first.+ fn fixture_with_an_exhausted_size() -> Document {+ let mut bytes = fixture();+ let text = String::from_utf8_lossy(&bytes).into_owned();+ let prev: usize = text.rsplit("startxref").next().and_then(|t| t.split_whitespace().next()).and_then(|n| n.parse().ok()).expect("startxref");+ let added = bytes.len();+ bytes.extend_from_slice(b"20 0 obj\n<< /Unused true >>\nendobj\n");+ let xref = bytes.len();+ bytes.extend_from_slice(+ format!(+ "xref\n20 1\n{added:010} 00000 n \ntrailer\n<< /Size 4294967295 /Root 1 0 R /Info 11 0 R /Prev {prev} >>\nstartxref\n{xref}\n%%EOF\n"+ )+ .as_bytes(),+ );+ let doc = open(bytes);+ assert!(doc.repair_log().iter().any(|l| l.contains("exhausted trailer")), "{:?}", doc.repair_log());+ doc+ }++ /// The fixture holding object 4294967295, as a document does once an edit writes to an object of+ /// that number (a damaged file's catalog, say). [`Document::add`] then fills free numbers below it.+ fn fixture_holding_object_4294967295() -> Document {+ let mut doc = open(fixture());+ doc.set(ObjRef::new(u32::MAX, 0), Object::String(PdfString::text("top")));+ doc+ }++ /// Documents whose new objects are numbered in the gaps below their highest number.+ fn documents_numbering_new_objects_below_their_highest() -> [(&'static str, Document); 2] {+ [("an exhausted /Size", fixture_with_an_exhausted_size()), ("object 4294967295", fixture_holding_object_4294967295())]+ }++ /// Duplicate, Replace and Insert Pages took the objects numbered above the destination's highest+ /// number for the ones the import added. When new objects fill gaps below it, the copies escaped+ /// resource sharing (each import stored the fonts again), and with object 4294967295 the number+ /// after the highest overflowed: a panic in debug builds, and in release a wrap to 0 that counted+ /// every object as added. The import now compares the object numbers before and after.+ #[test]+ fn an_import_shares_the_resources_it_added_wherever_they_are_numbered() {+ let mut plain = open(fixture());+ duplicate_pages(&mut plain, &[0], None).unwrap();+ for (what, mut doc) in documents_numbering_new_objects_below_their_highest() {+ let before = doc.object_numbers();+ duplicate_pages(&mut doc, &[0], None).unwrap();+ assert_eq!(labels(&doc), ["Page 1", "Page 1", "Page 2", "Page 3"], "{what}");+ assert_eq!(count_fonts(&doc), count_fonts(&plain), "{what}: the copy shares the font, as it does in the plain fixture");+ insert_file_pages(&mut doc, &open(fixture()), "Inserted", &[2], 0, FieldConflicts::Rename).unwrap();+ assert_eq!(labels(&doc), ["Page 3", "Page 1", "Page 1", "Page 2", "Page 3"], "{what}");+ assert_eq!(count_fonts(&doc), count_fonts(&plain), "{what}: the inserted page shares the font too");+ let after = doc.object_numbers();+ assert!(before.iter().all(|n| after.contains(n)), "{what}: every object the document had is still there");+ assert_eq!(labels(&full_roundtrip(&doc)), ["Page 3", "Page 1", "Page 1", "Page 2", "Page 3"], "{what}");+ }+ }++ /// A refused import takes back what it added, which in these documents is numbered below their+ /// highest object, and leaves the objects they had.+ #[test]+ fn a_refused_import_takes_back_what_it_added_wherever_it_is_numbered() {+ let run = std::thread::Builder::new()+ .stack_size(512 << 10)+ .spawn(|| {+ for (what, mut dst) in documents_numbering_new_objects_below_their_highest() {+ let before = (labels(&dst), dst.object_numbers());+ let err = import_pages(&mut dst, &chain(20_000), &[0], 0).unwrap_err();+ assert!(matches!(&err, OrganizeError::Invalid(m) if m.contains("levels deep")), "{what}: {err:?}");+ assert_eq!((labels(&dst), dst.object_numbers()), before, "{what}: the destination is as it was");+ }+ })+ .unwrap()+ .join();+ assert!(run.is_ok(), "a refused import must leave the document as it was, without panicking");+ }++/// What Edit ▸ Attach file added survives Combine files (upstream's writer), names+/// with accents included, and the combined document takes more attachments and deletions.+#[test]+fn attachments_added_in_the_app_survive_combine_and_more_can_be_attached() {+ let embedded = |doc: &Document, key: &str| -> (Vec<u8>, Option<String>) {+ let names = doc.resolve(catalog(doc).get(b"Names").unwrap()).as_dict().cloned().unwrap();+ let tree = doc.resolve(names.get(b"EmbeddedFiles").unwrap()).as_dict().cloned().unwrap();+ let pairs = tree.get(b"Names").and_then(|n| n.as_array()).cloned().unwrap();+ let at = pairs.chunks(2).position(|p| p[0].as_string().unwrap().to_text() == key).unwrap_or_else(|| panic!("no attachment {key}"));+ let spec = doc.resolve(&pairs[at * 2 + 1]).as_dict().cloned().unwrap();+ let desc = spec.get(b"Desc").and_then(Object::as_string).map(|s| s.to_text());+ let ef = spec.get(b"EF").and_then(Object::as_dict).unwrap().get(b"F").cloned().unwrap();+ let Object::Stream(stream) = doc.resolve(&ef).as_ref().clone() else { panic!("the embedded file is a stream") };+ (stream.decoded().unwrap(), desc)+ };+ let mut a = Document::open(Arc::new(fixture())).unwrap();+ add_attachment(&mut a, "invoice.csv", b"a,b", Some("March"), Some("text/csv"), None).unwrap();+ add_attachment(&mut a, "año.txt", b"uno", None, None, None).unwrap();+ let mut b = Document::open(Arc::new(fixture())).unwrap();+ add_attachment(&mut b, "invoice.csv", b"x,y", None, None, None).unwrap();+ add_attachment(&mut b, "año.txt", b"dos", None, None, None).unwrap();+ let a = save_and_reopen(&a);+ let b = save_and_reopen(&b);+ let mut out = full_roundtrip(&combine(&[("A", &a), ("B", &b)]).unwrap());+ // Both files' attachments, the second copies numbered as text (not bytes glued onto UTF-16).+ assert_eq!(attachment_keys(&out), ["invoice.csv", "invoice.csv (2)", "año.txt", "año.txt (2)"]);+ assert_eq!(embedded(&out, "invoice.csv"), (b"a,b".to_vec(), Some("March".into())));+ assert_eq!(embedded(&out, "invoice.csv (2)"), (b"x,y".to_vec(), None));+ assert_eq!(embedded(&out, "año.txt (2)").0, b"dos");+ // The combined document goes on taking attachments, and losing them, like any other.+ assert_eq!(add_attachment(&mut out, "invoice.csv", b"z", None, None, None).unwrap(), "invoice.csv (3)");+ delete_attachment(&mut out, "invoice.csv (2)").unwrap();+ let out = full_roundtrip(&out);+ assert_eq!(attachment_keys(&out), ["invoice.csv", "invoice.csv (3)", "año.txt", "año.txt (2)"]);+ assert_eq!(embedded(&out, "invoice.csv (3)").0, b"z");+}++#[test]+fn attachments_are_added_listed_and_deleted() {+ let mut doc = Document::open(Arc::new(fixture())).unwrap();+ assert!(attachment_keys(&doc).is_empty());+ // A path loses its folder; the key is the file name.+ let key = add_attachment(&mut doc, "/Users/eva/Desktop/invoice.csv", b"a,b\n1,2\n", Some("March"), Some("text/csv"), Some("D:20261012120000Z"))+ .unwrap();+ assert_eq!(key, "invoice.csv");+ // The same name again is kept apart.+ assert_eq!(add_attachment(&mut doc, "invoice.csv", b"x", None, None, None).unwrap(), "invoice.csv (2)");+ assert_eq!(add_attachment(&mut doc, " ", b"x", None, None, None), Err(OrganizeError::Invalid("the attachment needs a file name".into())));+ let doc = save_and_reopen(&doc);+ assert_eq!(attachment_keys(&doc), ["invoice.csv", "invoice.csv (2)"]);+ // What was written: a Filespec with the embedded stream, its size and type, and the description.+ let root = doc.root().unwrap();+ let names = doc.get(root).as_dict().unwrap().get(b"Names").cloned().unwrap();+ let tree = doc.resolve(&names).as_dict().unwrap().get(b"EmbeddedFiles").cloned().unwrap();+ let tree = doc.resolve(&tree);+ let pairs = tree.as_dict().unwrap().get(b"Names").cloned().unwrap();+ let pairs = doc.resolve(&pairs).as_array().cloned().unwrap();+ assert_eq!(pairs.len(), 4);+ let spec = doc.resolve(&pairs[1]);+ let spec = spec.as_dict().unwrap();+ assert_eq!(spec.get(b"Type"), Some(&Object::name("Filespec")));+ assert_eq!(spec.get(b"UF").and_then(Object::as_string).map(PdfString::to_text).as_deref(), Some("invoice.csv"));+ assert_eq!(spec.get(b"Desc").and_then(Object::as_string).map(PdfString::to_text).as_deref(), Some("March"));+ let ef = spec.get(b"EF").and_then(Object::as_dict).unwrap().get(b"F").cloned().unwrap();+ let ef = doc.resolve(&ef);+ let Object::Stream(stream) = ef.as_ref() else { panic!("the embedded file is a stream") };+ assert_eq!(stream.dict.get(b"Subtype"), Some(&Object::Name(b"text/csv".to_vec())));+ let params = stream.dict.get(b"Params").and_then(Object::as_dict).unwrap();+ assert_eq!(params.get(b"Size"), Some(&Object::Int(8)));+ assert_eq!(stream.decoded().unwrap(), b"a,b\n1,2\n");+ // Deleting: the one named goes, the other stays; the last one takes the tree with it.+ let mut doc = doc;+ delete_attachment(&mut doc, "invoice.csv").unwrap();+ assert_eq!(attachment_keys(&doc), ["invoice.csv (2)"]);+ assert_eq!(delete_attachment(&mut doc, "invoice.csv"), Err(OrganizeError::Invalid("there is no attachment named invoice.csv".into())));+ delete_attachment(&mut doc, "invoice.csv (2)").unwrap();+ let doc = save_and_reopen(&doc);+ assert!(attachment_keys(&doc).is_empty());+ assert!(doc.get(doc.root().unwrap()).as_dict().unwrap().get(b"Names").is_none());+}+#[test]fn rotate_repeated_indices_accumulate_from_the_current_page_value() {for level in 0..3 {diff --cc crates/ui-egui/src/i18n/es.tsvindex 03e3652d7,db00c69dd..c8d25e00e--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@@ -2621,11 -2635,183 +2635,188 @@@ animation effects Off Desactivado# Historical snapshot notice bar (View signed version / View revision).You are viewing the signed version of “{from}” (revision {rev}). It is a snapshot: changes here won't affect the original. Estás viendo la versión firmada de «{from}» (revisión {rev}). Es una instantánea: los cambios aquí no afectarán al original.You are viewing revision {rev} of “{from}”. It is a snapshot: changes here won't affect the original. Estás viendo la revisión {rev} de «{from}». Es una instantánea: los cambios aquí no afectarán al original.+ Attach a file… Adjuntar un archivo…+ Delete attachment Eliminar adjunto+ Attaching files is not available on the web yet Adjuntar archivos aún no está disponible en la web+ Attach {name} Adjuntar {name}+ Delete attachment {key} Eliminar adjunto {key}+ Thumbnail size Tamaño de las miniaturas+ Smaller thumbnails Miniaturas más pequeñas+ Larger thumbnails Miniaturas más grandes+ # Lines, connected lines and polygons reshaped by their ends and corners (M5).+ Reshape comment Cambiar la forma del comentario++ #+ # Keys the other catalogs carry that this one was missing, so Spanish covers the bundled key union+ # the way Lithuanian and Vietnamese do (`lithuanian_covers_bundled_catalog_keys_including_dynamic_dialog_labels`).+ # Same clean-room rule as the header: written from the plain meaning of the English label, reusing+ # the vocabulary already in this file (ID digital, marcador, Acercar / alejar, Portapapeles).+ #+ # The date picker.+ calendar date January enero+ calendar date February febrero+ calendar date March marzo+ calendar date April abril+ calendar date May mayo+ calendar date June junio+ calendar date July julio+ calendar date August agosto+ calendar date September septiembre+ calendar date October octubre+ calendar date November noviembre+ calendar date December diciembre+ calendar weekday Mo Lu+ calendar weekday Tu Ma+ calendar weekday We Mi+ calendar weekday Th Ju+ calendar weekday Fr Vi+ calendar weekday Sa Sá+ calendar weekday Su Do+ #+ # Certificate details, in their own context beside the plain labels.+ certificate Issued to Emitido a+ certificate Issued by Emitido por+ certificate Issuer Emisor+ certificate Serial number Número de serie+ certificate Version Versión+ certificate Public key Clave pública+ certificate Key usage Uso de la clave+ certificate Intended usage Uso previsto+ certificate Basic constraints Restricciones básicas+ certificate Self-signed Autofirmado+ certificate Valid from Válido desde+ certificate Valid to Válido hasta+ certificate Validity starts La validez empieza+ certificate Validity ends La validez termina+ certificate SHA-1 digest Huella SHA-1+ certificate SHA-256 digest Huella SHA-256+ #+ # What a certificate's key may be used for (X.509 key usage), as the details list them.+ Digital Signature Firma digital+ Non-Repudiation No repudio+ Key Encipherment Cifrado de claves+ Data Encipherment Cifrado de datos+ Key Agreement Acuerdo de claves+ Certificate Signing Firma de certificados+ CRL Signing Firma de CRL+ Encipher Only Solo cifrado+ Decipher Only Solo descifrado+ #+ # Signatures, revisions and digital IDs.+ {who}, certificate issued by {issuer}. {who}, certificado emitido por {issuer}.+ {who}, certificate issued by an unknown issuer. {who}, certificado emitido por un emisor desconocido.+ Rev. {rev}: Signed by {name} Rev. {rev}: Firmado por {name}+ Rev. {rev}: Signed by an unknown signer Rev. {rev}: Firmado por un firmante desconocido+ Rev. {rev}: Certified by {name} Rev. {rev}: Certificado por {name}+ Rev. {rev}: Certified by an unknown signer Rev. {rev}: Certificado por un firmante desconocido+ Unsigned signature field: {name} Campo de firma sin firmar: {name}+ Choose a digital ID. Elige un ID digital.+ There is no folder to save the digital ID in. No hay ninguna carpeta donde guardar el ID digital.+ #+ # Passwords.+ The password is incorrect. La contraseña es incorrecta.+ The password must have at least 6 characters. La contraseña debe tener al menos 6 caracteres.+ The password must have at least 8 characters. La contraseña debe tener al menos 8 caracteres.+ The passwords do not match. Las contraseñas no coinciden.+ Only the document's owner can change its security (open it with the permissions password) Solo el propietario del documento puede cambiar su seguridad (ábrelo con la contraseña de permisos)+ #+ # Counts.+ @plural {n} byte|{n} bytes {n} byte|{n} bytes+ @plural {n} pixel|{n} pixels {n} píxel|{n} píxeles+ @plural {n} file|{n} files {n} archivo|{n} archivos+ @plural {n} comment|{n} comments {n} comentario|{n} comentarios+ @plural {n} result|{n} results {n} resultado|{n} resultados+ @plural {n} image optimized|{n} images optimized {n} imagen optimizada|{n} imágenes optimizadas+ @plural {n} item discarded|{n} items discarded {n} elemento descartado|{n} elementos descartados+ @plural Delete {n} field|Delete {n} fields Eliminar {n} campo|Eliminar {n} campos+ #+ # Combining PDFs from a folder.+ Add the PDFs to combine Añade los PDF que vas a combinar+ Drop PDFs or folders here, or choose them. Suelta aquí PDF o carpetas, o elígelos.+ Every PDF in the folder Todos los PDF de la carpeta+ Every PDF in the folder and the folders inside it Todos los PDF de la carpeta y de las carpetas que contiene+ Added the first {n} PDFs in {folder} Se han añadido los primeros {n} PDF de {folder}+ No PDFs found in {folder} No se ha encontrado ningún PDF en {folder}+ #+ # Panels, rendering and notices.+ Panel layout could not be restored: {error} No se ha podido restaurar la disposición de los paneles: {error}+ Panel move was not applied: {error} No se ha aplicado el movimiento del panel: {error}+ Rendering… Renderizando…+ Still rendering — this page is unusually complex… Sigue renderizando: esta página es excepcionalmente compleja…+ Loading… Cargando…+ This file changed on disk. Reload it to see the new version; your unsaved changes will be lost. Este archivo cambió en el disco. Recárgalo para ver la versión nueva; se perderán los cambios sin guardar.+ Text recognition isn't installed: its models are missing (run `cargo xtask models`, or set PDFCRAFT_MODELS). El reconocimiento de texto no está instalado: faltan sus modelos (ejecuta `cargo xtask models` o define PDFCRAFT_MODELS).+ Cut and stack needs Two-sided: Off. Print single-sided sheets. Cortar y apilar necesita «A doble cara: Desactivado». Imprime hojas a una cara.+ Error Error+ Warning Advertencia+ Information Información+ Success Correcto+ #+ # Asking for something, and choosing it.+ Enter a name. Introduce un nombre.+ Enter a page number Introduce un número de página+ Enter a URL Introduce una URL+ Enter the field names Introduce los nombres de los campos+ Choose… Elegir…+ Choose a file… Elegir un archivo…+ Choose a folder… Elegir una carpeta…+ Create folder Crear carpeta+ Open folder Abrir carpeta+ Save file Guardar archivo+ Save changes? ¿Guardar los cambios?+ #+ # Settings and their values.+ Theme Tema+ theme Appearance Aspecto+ System Sistema+ English Inglés+ Always Siempre+ Never Nunca+ Automatically Automáticamente+ On Activado+ Enabled Activado+ Disabled Desactivado+ Mouse wheel scroll speed Velocidad de desplazamiento de la rueda del ratón+ Margins (in) Márgenes (pulg.)+ #+ # Labels and commands the catalogs name on their own.+ Color Color+ Folder Carpeta+ Comment Comentario+ Comment and review Comentar y revisar+ Creator Creador+ Producer Productor+ Organize Organizar+ Import Importar+ Move Mover+ Duplicate Duplicar+ Paste Pegar+ Select all Seleccionar todo+ Refresh Actualizar+ Next Siguiente+ Previous Anterior+ of de+ No results Sin resultados+ Search results Resultados de la búsqueda+ Copy to clipboard Copiar al portapapeles+ Copied to clipboard Copiado al portapapeles+ Help… Ayuda…+ on page {label} en la página {label}+ Page {n} Página {n}+ Page {n} of {total} Página {n} de {total}+ #+ # Tooltips that spell their shortcut out.+ Open a PDF (⌘O) Abrir un PDF (⌘O)+ Print (⌘P) Imprimir (⌘P)+ Document properties (⌘D) Propiedades del documento (⌘D)+ New bookmark (⌘B) Nuevo marcador (⌘B)+ Next (⌘G) Siguiente (⌘G)+ Previous (⇧⌘G) Anterior (⇧⌘G)+ Zoom in (⌘+) Acercar (⌘+)+ Zoom out (⌘−) Alejar (⌘−)+ Zoom in / out (also pinch or ⌘-scroll) Acercar / alejar (también con pellizco o ⌘ + desplazamiento)+ Rotate view clockwise (⇧⌘+) Girar la vista a la derecha (⇧⌘+)+ Save (M4) Guardar (M4)# Prepare a form ▸ Text field tableAdd text field table Añadir tabla de campos de textodiff --cc crates/ui-egui/src/i18n/pt-br.tsvindex 97ec9dfc0,8fe72f99b..cc9460984--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@@ -2486,11 -2495,62 +2495,67 @@@ animation effects Off DesativadoMake properties default Tornar propriedades padrãoPages selected Páginas selecionadasPage properties Propriedades da página+ Attach a file… Anexar um arquivo…+ Delete attachment Excluir anexo+ Attaching files is not available on the web yet Anexar arquivos ainda não está disponível na web+ Attach {name} Anexar {name}+ Delete attachment {key} Excluir anexo {key}++ # Remaining keys from the current catalog union, translated from their English meaning (2026-10-21).+ on page {label} na página {label}+ A font isn't embedded Uma fonte não está incorporada+ A {} action isn't allowed A ação {} não é permitida+ A {} annotation has additional actions A anotação {} tem ações adicionais+ A {} annotation has no appearance stream A anotação {} não tem fluxo de aparência+ A {} annotation isn't set to print, or is hidden A anotação {} não está configurada para impressão ou está oculta+ Accessibility Report Relatório de acessibilidade+ Add the PDFs to combine Adicione os PDFs que deseja combinar+ Added the first {n} PDFs in {folder} Os primeiros {n} PDFs de {folder} foram adicionados+ Always Sempre+ Automatically Automaticamente+ CRL Signing Assinatura de CRL+ Certificate Signing Assinatura de certificado+ Change Author Alterar autor+ Change Keywords Alterar palavras-chave+ Change Subject Alterar assunto+ Change Title Alterar título+ Choose a digital ID. Escolha uma identidade digital.+ Choose a file… Escolher um arquivo…+ Choose a folder… Escolher uma pasta…+ Choose… Escolher…+ Color Cor+ Comment Comentário+ Comment and review Comentar e revisar+ Copied to clipboard Copiado para a área de transferência+ Copy to clipboard Copiar para a área de transferência+ Create folder Criar pasta+ Create links Criar links+ Creator Criador+ Cut and stack needs Two-sided: Off. Print single-sided sheets. Recortar e empilhar requer Frente e verso: desativado. Imprima em folhas de um só lado.+ Data Encipherment Criptografia de dados+ Decipher Only Somente descriptografia+ Detailed Report Relatório detalhado+ DeviceCMYK is used, but the PDF/A output intent isn't a CMYK profile O DeviceCMYK está em uso, mas o perfil de saída do PDF/A não é um perfil CMYK+ DeviceRGB is used, but the PDF/A output intent isn't an RGB profile O DeviceRGB está em uso, mas o perfil de saída do PDF/A não é um perfil RGB+ Digital Signature Assinatura digital+ Disabled Desativado+ Document properties (⌘D) Propriedades do documento (⌘D)+ Drop PDFs or folders here, or choose them. Solte PDFs ou pastas aqui, ou selecione-os.+ Duplicate Duplicar+ Enabled Ativado+ Encipher Only Somente criptografia+ English Inglês+ Enter a URL Informe uma URL+ Enter a name. Informe um nome.+ Enter a page number Informe o número da página+ Enter the field names Informe os nomes dos campos+ Error Erro+ Every PDF in the folder Todos os PDFs da pasta+ Every PDF in the folder and the folders inside it Todos os PDFs da pasta e de suas subpastas+ Field "{}" on page {p} has no description (tooltip) O campo "{}" na página {p} não tem descrição (dica de ferramenta)+ Filename Nome do arquivo+ Flatten Fill & Sign Achatar Preencher e assinar+ Folder PastaFont FonteBulleted list Lista com marcadoresNumbered list Lista numeradadiff --cc crates/ui-egui/src/i18n/vi.tsvindex ab6429b8e,bb20dcc5b..65af9d790--- a/crates/ui-egui/src/i18n/vi.tsv+++ b/crates/ui-egui/src/i18n/vi.tsv@@@ -2733,11 -2746,14 +2746,19 @@@ key Space Spac# Historical snapshot notice bar (View signed version / View revision).You are viewing the signed version of “{from}” (revision {rev}). It is a snapshot: changes here won't affect the original. Bạn đang xem phiên bản đã ký của “{from}” (bản sửa đổi {rev}). Đây là ảnh nhanh: các thay đổi ở đây không được áp dụng đến bản gốc.You are viewing revision {rev} of “{from}”. It is a snapshot: changes here won't affect the original. Bạn đang xem bản sửa đổi {rev} của “{from}”. Đây là ảnh nhanh: các thay đổi ở đây không được áp dụng đến bản gốc.+ Attach a file… Đính kèm tệp…+ Delete attachment Xóa tệp đính kèm+ Attaching files is not available on the web yet Chưa thể đính kèm tệp trên web+ Attach {name} Đính kèm {name}+ Delete attachment {key} Xóa tệp đính kèm {key}+ Thumbnail size Kích thước hình thu nhỏ+ Smaller thumbnails Giảm kích thước hình thu nhỏ+ Larger thumbnails Tăng kích thước hình thu nhỏ+ # Lines, connected lines and polygons reshaped by their ends and corners (M5).+ Reshape comment Đổi hình dạng nhận xét++ # AI-assisted additions for reading printer options off the GUI thread (#1818) (2026-10-16); not reviewed by a native speaker.+ Reading the printer's settings… Đang đọc cài đặt của máy in…# Prepare a form ▸ Text field tableAdd text field table Thêm bảng trường văn bản