mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-30 04:58:34 -06:00
Merge PR #2724: fix(print): disable Print on documents whose security forbids printing
ATTRIBUTION.toml: kept main's sha256 lines; hashes recomputed after the track. crates/ui-egui/tests/print.rs: kept both sides' tests.
This commit is contained in:
@@ -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<DocId>)
|
||||
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()),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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(),
|
||||
};
|
||||
|
||||
@@ -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 انقر على نص أو صورة لتحريرها
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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 Щракнете върху текст или изображение, за да го редактирате
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 16.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 51.
|
@@ -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:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 477 and column 9.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 60.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 39.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 7 and column 44.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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 テキストまたは画像をクリックして編集
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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-ке кірмейді:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 856 and column 9.
|
@@ -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.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 404 and column 9.
|
@@ -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ć
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 9 and column 16.
|
@@ -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 Щёлкните текст или изображение, чтобы редактировать
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 9 and column 16.
|
@@ -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:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 9 and column 16.
|
@@ -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 సవరించడానికి టెక్స్ట్ లేదా చిత్రంపై క్లిక్ చేయండి
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 13 and column 16.
|
@@ -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:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 855 and column 9.
|
@@ -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 Клацніть текст або зображення для редагування
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 491 and column 12.
|
@@ -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 单击文本或图像进行编辑
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 9 and column 16.
|
@@ -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 按一下文字或圖片進行編輯
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 9 and column 16.
|
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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]]
|
||||
|
||||
Reference in New Issue
Block a user