diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index 9958763d19..58d1b2ddb7 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -26,6 +26,8 @@ pub enum Needs { Annotate, /// The open document's security allows copying text and images out of it. Copying, + /// The open document's security allows printing (low resolution counts). + Printing, /// The document has form fields and its security allows filling them in. FillForms, /// The document has comments and allows changes. @@ -188,7 +190,7 @@ pub const COMMANDS: &[CommandSpec] = &[ c("file.close", "Close file", FILE, Some(Shortcut::cmd("W")), Document, "x"), c("file.close_all", "Close all", FILE, Some(Shortcut::cmd_shift("W")), Document, "x"), c("file.revert", "Revert", FILE, None, Undo, "rotate-ccw"), - c("print.dialog", "Print…", FILE, Some(Shortcut::cmd("P")), Document, "printer"), + c("print.dialog", "Print…", FILE, Some(Shortcut::cmd("P")), Printing, "printer"), c("file.properties", "Document properties…", FILE, Some(Shortcut::cmd("D")), Document, "info"), c("file.word_count", "Word count…", FILE, None, Copying, "hash"), ct("edit.undo", "Undo", EDIT, Some(Shortcut::cmd("Z")), Undo, "undo-2"), @@ -399,6 +401,7 @@ pub fn is_enabled(spec: &CommandSpec, session: &Session, active: Option) Modification => doc.is_some_and(|d| d.allows_modification()), Annotate => doc.is_some_and(|d| d.allows_annotation()), Copying => doc.is_some_and(|d| d.allows_copying()), + Printing => doc.is_some_and(|d| d.allows_printing()), FillForms => doc.is_some_and(|d| d.allows_form_filling() && !d.form.is_empty()), Marks(k) => doc.is_some_and(|d| d.allows_modification() && d.marks().contains(&k)), HasComments => doc.is_some_and(|d| d.allows_modification() && !d.info.annotations.is_empty()), diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 080dc32dd3..d433048418 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -1210,6 +1210,24 @@ fn copy_restricted_documents_refuse_extraction_unless_opened_by_the_owner() { assert!(s.get(plain).unwrap().check_copying().is_ok() && extracting.iter().all(|c| enabled(&s, plain, c))); } +/// Table 22, bit 3 (#2669): a document that forbids printing disables Print up front instead +/// of refusing once the dialog is confirmed. Low-resolution printing (bit 3 on, bit 12 off) is +/// still printing, and the owner password lifts the restriction. +#[test] +fn print_restricted_documents_disable_print_unless_opened_by_the_owner() { + let enabled = |s: &Session, id, c| commands::is_enabled(commands::command(c).unwrap(), s, Some(id)); + let bytes = protected("", "owner", -1 ^ 0b100); + let mut s = Session::new(); + let id = s.open("r.pdf", None, bytes.clone(), None).unwrap(); + assert!(!s.get(id).unwrap().allows_printing()); + assert!(!enabled(&s, id, "print.dialog")); + assert!(enabled(&s, id, "export.text"), "only printing is withheld"); + let oid = s.open("r.pdf", None, bytes, Some("owner")).unwrap(); + assert!(enabled(&s, oid, "print.dialog"), "the owner may print"); + let low = s.open("low.pdf", None, protected("", "owner", -1 ^ (1 << 11)), None).unwrap(); + assert!(enabled(&s, low, "print.dialog"), "low-resolution printing is printing"); +} + #[test] fn the_permissions_password_unlocks_an_open_document() { // Only a permissions password (#995, #1077): opens without asking. Changes are allowed, diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index 48d1d3c44c..4ec874752e 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -512,7 +512,13 @@ pub fn mode_bar(app: &mut PdfCraftApp, ui: &mut egui::Ui) { let has_doc = app.active.is_some(); ui.add_enabled_ui(has_doc, |ui| { let tip = crate::commands::command_tip(ui.ctx(), tl!("Print ({key})"), "print.dialog"); - if icons::button(ui, "printer", 32.0, false, &tip).clicked() { + // A document that forbids printing says so here, before the dialog (#2669). + let may_print = !has_doc || pdfcraft_engine::commands::command("print.dialog").is_some_and(|c| app.command_enabled(c)); + let mut print = ui.add_enabled_ui(may_print, |ui| icons::button(ui, "printer", 32.0, false, &tip)).inner; + if !may_print { + print = print.on_disabled_hover_text(crate::print_refused()); + } + if print.clicked() { app.run_command("print.dialog"); } let tip = crate::commands::command_tip(ui.ctx(), tl!("Save ({key})"), "file.save"); diff --git a/crates/ui-egui/src/commands.rs b/crates/ui-egui/src/commands.rs index 49a0e20b77..a0bebd5b56 100644 --- a/crates/ui-egui/src/commands.rs +++ b/crates/ui-egui/src/commands.rs @@ -143,6 +143,7 @@ impl PdfCraftApp { tl!("The document's security settings don't allow this change").to_string() } commands::Needs::Copying if self.active.is_some() => crate::copy_refused().to_string(), + commands::Needs::Printing if self.active.is_some() => crate::print_refused().to_string(), commands::Needs::TwoPageView if self.active.is_some() => tl!("Switch to two-page view first to show the cover page").to_string(), _ => tl!("Open a document first").to_string(), }; diff --git a/crates/ui-egui/src/i18n/ar.tsv b/crates/ui-egui/src/i18n/ar.tsv index faed744a05..79cfe55345 100644 --- a/crates/ui-egui/src/i18n/ar.tsv +++ b/crates/ui-egui/src/i18n/ar.tsv @@ -1796,6 +1796,7 @@ This document has no restrictions to lift لا توجد في هذا المستند قيود لرفعها The document's security settings don't allow this change إعدادات أمان المستند لا تسمح بهذا التغيير The document's security settings don't allow copying text and images إعدادات أمان المستند لا تسمح بنسخ النصوص والصور + The document's security settings don't allow printing إعدادات أمان المستند لا تسمح بالطباعة Open a document first افتح مستندًا أولًا Security will be removed when you save سيُزال الأمان عند الحفظ Click text or an image to edit it انقر على نص أو صورة لتحريرها diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index c41c1d5f5c..59d274179b 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -1759,6 +1759,7 @@ This document has no restrictions to lift Този документ няма ограничения за премахване The document's security settings don't allow this change Настройките за защита на документа не позволяват тази промяна The document's security settings don't allow copying text and images Настройките за защита на документа не позволяват копиране на текст и изображения + The document's security settings don't allow printing Настройките за защита на документа не позволяват печат Open a document first Първо отворете документ Security will be removed when you save Защитата ще бъде премахната при записване Click text or an image to edit it Щракнете върху текст или изображение, за да го редактирате diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 9a9f0777c1..e1fe3efb86 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -1842,6 +1842,7 @@ key Space Mezerník Only the document's owner can change its security (open it with the permissions password) Zabezpečení může změnit jen vlastník dokumentu (otevřete ho heslem oprávnění) The document's security settings don't allow this change Nastavení zabezpečení dokumentu tuto změnu nedovoluje The document's security settings don't allow copying text and images Nastavení zabezpečení dokumentu nedovoluje kopírovat text a obrázky + The document's security settings don't allow printing Nastavení zabezpečení dokumentu nedovoluje tisk Open a document first Nejdřív otevřete dokument Security will be removed when you save Zabezpečení se odebere při uložení Click text or an image to edit it Kliknutím na text nebo obrázek ho upravíte diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index c05220b443..962d898be1 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -1732,6 +1732,7 @@ This document has no restrictions to lift Dieses Dokument hat keine Einschränkungen, die aufgehoben werden können The document's security settings don't allow this change Die Sicherheitseinstellungen des Dokuments erlauben diese Änderung nicht The document's security settings don't allow copying text and images Die Sicherheitseinstellungen des Dokuments erlauben kein Kopieren von Text und Bildern + The document's security settings don't allow printing Die Sicherheitseinstellungen des Dokuments erlauben kein Drucken Open a document first Öffne zuerst ein Dokument Security will be removed when you save Die Sicherheit wird beim Speichern entfernt Click text or an image to edit it Klicke auf Text oder ein Bild, um es zu bearbeiten diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 29717bbef8..788c3bb838 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -2296,6 +2296,7 @@ comment menu Edit Επεξεργασία Couldn't unlock {name}: {e} Δεν ήταν δυνατό το ξεκλείδωμα του {name}: {e} This document has no restrictions to lift Αυτό το έγγραφο δεν έχει περιορισμούς προς άρση The document's security settings don't allow copying text and images Οι ρυθμίσεις ασφαλείας του εγγράφου δεν επιτρέπουν την αντιγραφή κειμένου και εικόνων + The document's security settings don't allow printing Οι ρυθμίσεις ασφαλείας του εγγράφου δεν επιτρέπουν την εκτύπωση Add the files to combine Προσθέστε τα αρχεία προς συνδυασμό Leave out files that can't be read? Να παραλειφθούν τα αρχεία που δεν διαβάζονται; These files can't be read, so they won't be in the combined PDF: Αυτά τα αρχεία δεν διαβάζονται, οπότε δεν θα συμπεριληφθούν στο συνδυασμένο PDF: diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 79518a080a..41423dec33 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -1809,6 +1809,7 @@ action wizard Start Iniciar This document has no restrictions to lift Este documento no tiene restricciones que quitar The document's security settings don't allow this change La configuración de seguridad del documento no permite este cambio The document's security settings don't allow copying text and images La configuración de seguridad del documento no permite copiar texto ni imágenes + The document's security settings don't allow printing La configuración de seguridad del documento no permite imprimir Open a document first Abre primero un documento Security will be removed when you save La seguridad se quitará al guardar Click text or an image to edit it Haz clic en un texto o una imagen para editarlo diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index dc5a0e9f96..acf6146240 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -1727,6 +1727,7 @@ This document has no restrictions to lift Ce document n'a aucune restriction à lever The document's security settings don't allow this change Les paramètres de protection du document n'autorisent pas cette modification The document's security settings don't allow copying text and images Les paramètres de protection du document n'autorisent pas la copie de texte et d'images + The document's security settings don't allow printing Les paramètres de protection du document n'autorisent pas l'impression Open a document first Ouvrez d'abord un document Security will be removed when you save La protection sera retirée à l'enregistrement Click text or an image to edit it Cliquez sur un texte ou une image pour le modifier diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index fd5f0c768a..10ea6ba99b 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -1717,6 +1717,7 @@ This document has no restrictions to lift Ebben a dokumentumban nincs feloldható korlátozás The document's security settings don't allow this change A dokumentum biztonsági beállításai nem engedik ezt a módosítást The document's security settings don't allow copying text and images A dokumentum biztonsági beállításai nem engedik a szöveg és a képek másolását + The document's security settings don't allow printing A dokumentum biztonsági beállításai nem engedik a nyomtatást Open a document first Előbb nyiss meg egy dokumentumot Security will be removed when you save A védelem mentéskor megszűnik Click text or an image to edit it Kattints a szövegre vagy egy képre a szerkesztéshez diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 541be0deb8..2ed954cc4d 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -1803,6 +1803,7 @@ This document has no restrictions to lift Questo documento non ha restrizioni da rimuovere The document's security settings don't allow this change Le impostazioni di sicurezza del documento non consentono questa modifica The document's security settings don't allow copying text and images Le impostazioni di sicurezza del documento non consentono di copiare testo e immagini + The document's security settings don't allow printing Le impostazioni di sicurezza del documento non consentono la stampa Open a document first Apri prima un documento Security will be removed when you save La protezione verrà rimossa al salvataggio Click text or an image to edit it Fai clic su un testo o un'immagine per modificarlo diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index ef27ac34e3..9c4a291aab 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -1808,6 +1808,7 @@ This document has no restrictions to lift この文書には解除する制限がありません The document's security settings don't allow this change 文書のセキュリティ設定により、この変更は許可されていません The document's security settings don't allow copying text and images 文書のセキュリティ設定により、テキストと画像のコピーは許可されていません + The document's security settings don't allow printing 文書のセキュリティ設定により、印刷は許可されていません Open a document first 先に文書を開いてください Security will be removed when you save セキュリティは保存時に解除されます Click text or an image to edit it テキストまたは画像をクリックして編集 diff --git a/crates/ui-egui/src/i18n/kk.tsv b/crates/ui-egui/src/i18n/kk.tsv index 41d61fa02a..2379c8aaf6 100644 --- a/crates/ui-egui/src/i18n/kk.tsv +++ b/crates/ui-egui/src/i18n/kk.tsv @@ -2286,6 +2286,7 @@ key Space Бос орын Couldn't unlock {name}: {e} {name} құлпын ашу мүмкін болмады: {e} This document has no restrictions to lift Бұл құжатта алып тасталатын шектеулер жоқ The document's security settings don't allow copying text and images Құжаттың қауіпсіздік параметрлері мәтін мен суреттерді көшіруге рұқсат бермейді + The document's security settings don't allow printing Құжаттың қауіпсіздік параметрлері басып шығаруға рұқсат бермейді Add the files to combine Біріктірілетін файлдарды қосыңыз Leave out files that can't be read? Оқылмайтын файлдарды қалдырып кету керек пе? These files can't be read, so they won't be in the combined PDF: Бұл файлдар оқылмайды, сондықтан біріктірілген PDF-ке кірмейді: diff --git a/crates/ui-egui/src/i18n/lt.tsv b/crates/ui-egui/src/i18n/lt.tsv index 1e8b6adac5..9f6b2bcc1c 100644 --- a/crates/ui-egui/src/i18n/lt.tsv +++ b/crates/ui-egui/src/i18n/lt.tsv @@ -1177,6 +1177,7 @@ The document now conforms to {level}; save it to keep the changes Dokumentas dabar atitinka {level}; įrašykite jį, kad išsaugotumėte pakeitimus The document opens without a password; this password is needed to change the restrictions. It's applied when you save. Dokumentą galima atverti be slaptažodžio; šis slaptažodis reikalingas apribojimams keisti. Jis pritaikomas įrašant dokumentą. The document's security settings don't allow copying text and images Dokumento saugos nuostatos neleidžia kopijuoti teksto ir paveikslėlių + The document's security settings don't allow printing Dokumento saugos nuostatos neleidžia spausdinti The document's security settings don't allow this change Dokumento saugos nuostatos neleidžia atlikti šio pakeitimo The existing action will be preserved. Esamas veiksmas bus išsaugotas. The fonts PdfCraft writes with can't draw “{c}” ({code}), so it shows as ? in every PDF viewer. The text is saved. „PdfCraft“ naudojami šriftai negali atvaizduoti simbolio „{c}“ ({code}), todėl visose PDF žiūryklėse jis rodomas kaip ?. Tekstas įrašytas. diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index dae8da86a0..5fce6e6216 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -1790,6 +1790,7 @@ Couldn't unlock {name}: {e} Nie udało się odblokować pliku {name}: {e} This document has no restrictions to lift Ten dokument nie ma ograniczeń do zniesienia The document's security settings don't allow this change Ustawienia zabezpieczeń dokumentu nie zezwalają na tę zmianę + The document's security settings don't allow printing Ustawienia zabezpieczeń dokumentu nie zezwalają na drukowanie Open a document first Najpierw otwórz dokument Security will be removed when you save Zabezpieczenia zostaną usunięte przy zapisie Click text or an image to edit it Kliknij tekst lub obraz, aby go edytować diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 956f322337..591ed2e655 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -1631,6 +1631,7 @@ This document has no restrictions to lift Este documento não tem restrições a remover The document's security settings don't allow this change As configurações de segurança do documento não permitem esta alteração The document's security settings don't allow copying text and images As configurações de segurança do documento não permitem copiar texto e imagens + The document's security settings don't allow printing As configurações de segurança do documento não permitem imprimir Open a document first Abra um documento primeiro Security will be removed when you save A segurança será removida ao salvar Click text or an image to edit it Clique no texto ou em uma imagem para editá-lo diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 399482f013..7c2fbdbd74 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -1797,6 +1797,7 @@ This document has no restrictions to lift У этого документа нет ограничений, которые можно снять The document's security settings don't allow this change Настройки безопасности документа не разрешают это изменение The document's security settings don't allow copying text and images Настройки безопасности документа не разрешают копировать текст и изображения + The document's security settings don't allow printing Настройки безопасности документа не разрешают печать Open a document first Сначала откройте документ Security will be removed when you save Безопасность будет удалена при сохранении Click text or an image to edit it Щёлкните текст или изображение, чтобы редактировать diff --git a/crates/ui-egui/src/i18n/sl.tsv b/crates/ui-egui/src/i18n/sl.tsv index 3adb944471..f018e03844 100644 --- a/crates/ui-egui/src/i18n/sl.tsv +++ b/crates/ui-egui/src/i18n/sl.tsv @@ -2301,6 +2301,7 @@ key Space Preslednica Couldn't unlock {name}: {e} Dokumenta {name} ni bilo mogoče odkleniti: {e} This document has no restrictions to lift Ta dokument nima omejitev, ki bi jih bilo treba odpraviti The document's security settings don't allow copying text and images Varnostne nastavitve dokumenta ne dovolijo kopiranja besedila in slik + The document's security settings don't allow printing Varnostne nastavitve dokumenta ne dovolijo tiskanja Add the files to combine Dodajte datoteke za združevanje Leave out files that can't be read? Izpustim datoteke, ki jih ni mogoče prebrati? These files can't be read, so they won't be in the combined PDF: Teh datotek ni mogoče prebrati, zato ne bodo v združenem PDF-ju: diff --git a/crates/ui-egui/src/i18n/te.tsv b/crates/ui-egui/src/i18n/te.tsv index cc74f279ea..226bcc4f63 100644 --- a/crates/ui-egui/src/i18n/te.tsv +++ b/crates/ui-egui/src/i18n/te.tsv @@ -1716,6 +1716,7 @@ action wizard Start ప్రారంభించు This document has no restrictions to lift ఈ పత్రంలో తొలగించాల్సిన పరిమితులు లేవు The document's security settings don't allow this change పత్రం భద్రతా సెట్టింగ్‌లు ఈ మార్పును అనుమతించవు The document's security settings don't allow copying text and images పత్రం భద్రతా సెట్టింగ్‌లు టెక్స్ట్, చిత్రాలను కాపీ చేయడాన్ని అనుమతించవు + The document's security settings don't allow printing పత్రం భద్రతా సెట్టింగ్‌లు ముద్రించడాన్ని అనుమతించవు Open a document first ముందుగా ఒక పత్రాన్ని తెరవండి Security will be removed when you save మీరు సేవ్ చేసినప్పుడు భద్రత తీసివేయబడుతుంది Click text or an image to edit it సవరించడానికి టెక్స్ట్ లేదా చిత్రంపై క్లిక్ చేయండి diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index dad1423e48..89f2379e22 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2292,6 +2292,7 @@ key Space Boşluk Couldn't unlock {name}: {e} {name} kilidi açılamadı: {e} This document has no restrictions to lift Bu belgede kaldırılacak kısıtlama yok The document's security settings don't allow copying text and images Belgenin güvenlik ayarları metin ve resimlerin kopyalanmasına izin vermiyor + The document's security settings don't allow printing Belgenin güvenlik ayarları yazdırmaya izin vermiyor Add the files to combine Birleştirilecek dosyaları ekleyin Leave out files that can't be read? Okunamayan dosyalar dışarıda bırakılsın mı? These files can't be read, so they won't be in the combined PDF: Bu dosyalar okunamıyor, bu yüzden birleştirilmiş PDF'de yer almayacak: diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index c6cf0bd137..5858e929de 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -1794,6 +1794,7 @@ This document has no restrictions to lift Цей документ не має обмежень, які можна зняти The document's security settings don't allow this change Налаштування захисту документа не дозволяють цю зміну The document's security settings don't allow copying text and images Налаштування захисту документа не дозволяють копіювати текст і зображення + The document's security settings don't allow printing Налаштування захисту документа не дозволяють друк Open a document first Спочатку відкрийте документ Security will be removed when you save Захист буде знято під час збереження Click text or an image to edit it Клацніть текст або зображення для редагування diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 9a75558378..94ec2770d6 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -1167,6 +1167,7 @@ theme Appearance Giao diện The document now conforms to {level}; save it to keep the changes Tài liệu hiện tuân thủ {level}; hãy lưu để giữ các thay đổi The document opens without a password; this password is needed to change the restrictions. It's applied when you save. Tài liệu mở không cần mật khẩu; mật khẩu này cần để thay đổi các hạn chế. Mật khẩu được áp dụng khi bạn lưu. The document's security settings don't allow copying text and images Cài đặt bảo mật của tài liệu không cho phép sao chép văn bản và hình ảnh + The document's security settings don't allow printing Cài đặt bảo mật của tài liệu không cho phép in The document's security settings don't allow this change Cài đặt bảo mật của tài liệu không cho phép thay đổi này The existing action will be preserved. Hành động hiện có sẽ được giữ nguyên. The fonts PdfCraft writes with can't draw “{c}” ({code}), so it shows as ? in every PDF viewer. The text is saved. Phông chữ mà PdfCraft dùng để ghi không thể vẽ “{c}” ({code}), nên nó hiển thị là ? trong mọi trình xem PDF. Văn bản vẫn được lưu. diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 980e49ea0d..632747ce1c 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -1766,6 +1766,7 @@ This document has no restrictions to lift 此文档没有可解除的限制 The document's security settings don't allow this change 文档安全设置不允许此更改 The document's security settings don't allow copying text and images 文档安全设置不允许复制文本和图像 + The document's security settings don't allow printing 文档安全设置不允许打印 Open a document first 请先打开文档 Security will be removed when you save 保存时将删除安全性设置 Click text or an image to edit it 单击文本或图像进行编辑 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index a89973aa37..d378322d51 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -1709,6 +1709,7 @@ This document has no restrictions to lift 此文件沒有可解除的限制 The document's security settings don't allow this change 文件安全設定不允許此更改 The document's security settings don't allow copying text and images 文件安全設定不允許複製文字和圖片 + The document's security settings don't allow printing 文件安全設定不允許列印 Open a document first 請先開啟文件 Security will be removed when you save 儲存時將刪除安全性設定 Click text or an image to edit it 按一下文字或圖片進行編輯 diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 33be025b09..54c43d26d3 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -2884,6 +2884,10 @@ pub(crate) fn copy_refused() -> &'static str { tl!("The document's security settings don't allow copying text and images") } +pub(crate) fn print_refused() -> &'static str { + tl!("The document's security settings don't allow printing") +} + impl PdfCraftApp { /// Whether text and images may be copied out of document `id`; says why not when they may /// not. Reading aloud and accessibility tools don't ask (assistive technology may read diff --git a/crates/ui-egui/tests/print.rs b/crates/ui-egui/tests/print.rs index 37514bcec0..45adcb0666 100644 --- a/crates/ui-egui/tests/print.rs +++ b/crates/ui-egui/tests/print.rs @@ -686,3 +686,53 @@ fn a_dead_options_read_wakes_an_idle_dialog() { h.run(); assert_eq!(h.state().print_draft.driver_options, Some(("Office".into(), Vec::new()))); } + +/// A document whose security forbids printing (#2669) says so before the dialog opens, and the +/// top bar's Print button is disabled, instead of the dialog refusing on confirm. +#[test] +fn print_restricted_documents_say_so_before_the_dialog() { + let mut doc = pdfcraft_cos::Document::open(std::sync::Arc::new(include_bytes!("data/form.pdf").to_vec())).unwrap(); + doc.set_encryption(&pdfcraft_cos::NewEncryption { + algorithm: pdfcraft_cos::Algorithm::Aes256, + user_password: "", + owner_password: "owner", + permissions: -1 ^ 0b100, + encrypt_metadata: true, + seed: [3; 32], + }) + .unwrap(); + let bytes = pdfcraft_cos::write_full(&doc, &Default::default()).unwrap(); + let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_| { + let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); + app.open_bytes("restricted.pdf", None, bytes).unwrap(); + app + }); + h.ctx.set_os(egui::os::OperatingSystem::Windows); + h.run_steps(4); + assert!(h.get_by_label("Print (Ctrl+P)").accesskit_node().is_disabled()); + h.get_by_label("Print (Ctrl+P)").hover(); + h.run_steps(30); + h.get_by_label_contains("don't allow printing"); + assert!(!h.state_mut().execute("print.dialog")); + h.run_steps(2); + assert_eq!(h.state().dialog, None); + assert_eq!(h.state().toast.as_ref().map(|t| t.0.as_str()), Some("The document's security settings don't allow printing")); +} + +/// With no document open the top bar's Print button is disabled too, but not for security +/// reasons: its tooltip must not blame the document's settings (#2669). +#[test] +fn print_without_a_document_does_not_blame_security() { + let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_| { + let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); + app + }); + h.ctx.set_os(egui::os::OperatingSystem::Windows); + h.run_steps(4); + assert!(h.get_by_label("Print (Ctrl+P)").accesskit_node().is_disabled()); + h.get_by_label("Print (Ctrl+P)").hover(); + h.run_steps(30); + assert!(h.query_by_label_contains("don't allow printing").is_none()); +} diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml index b1540afd7a..a4132c01b3 100644 --- a/parity/acrobat-features.toml +++ b/parity/acrobat-features.toml @@ -214,7 +214,7 @@ milestone = "M1" status = "shipped" commands = [] tools = [] -evidence = ["crates/ui-egui/tests/editing.rs::restricted_documents_show_a_notice_and_block_page_changes", "crates/crypt/src/tests.rs::permission_bits_follow_table_22", "crates/crypt/src/tests.rs::perms_limits_what_an_edited_p_grants", "crates/engine/src/tests.rs::combining_protected_files_is_refused_clearly"] +evidence = ["crates/ui-egui/tests/editing.rs::restricted_documents_show_a_notice_and_block_page_changes", "crates/crypt/src/tests.rs::permission_bits_follow_table_22", "crates/crypt/src/tests.rs::perms_limits_what_an_edited_p_grants", "crates/engine/src/tests.rs::combining_protected_files_is_refused_clearly", "crates/engine/src/tests.rs::print_restricted_documents_disable_print_unless_opened_by_the_owner", "crates/ui-egui/tests/print.rs::print_restricted_documents_say_so_before_the_dialog"] notes = "" [[feature]]