Browse Source

【加密】拥有权限密码的文档不能编辑,架上点击编辑PDF、数字签名、标记密文都提示“此文档为加密文档,不允许编辑”

liujiajie 10 months ago
parent
commit
017471833e

+ 7 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -210,6 +210,13 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
                 KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
                 return
             }
+            if self.pdfView.document.permissionsStatus != .owner /*!self.pdfView.document!.allowsPrinting || !self.pdfView.document!.allowsCopying*/ {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
+                alert.runModal()
+                return
+            }
             Task { @MainActor in
                 self.delegate?.toolbarViewController?(self, clickMode: tag, toolbar: item.clickObject as! KMToolbarItemView, [])
             }

+ 7 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -4594,6 +4594,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 } else if itemID == KMDocumentScanOCRToolbarItemIdentifier {
                     showOCRWindow()
                 } else if itemID == KMDocumentDigitalSignToolbarItemIdentifier {
+                    if self.listView.document.permissionsStatus != .owner /*!self.pdfView.document!.allowsPrinting || !self.pdfView.document!.allowsCopying*/ {
+                        let alert = NSAlert()
+                        alert.alertStyle = .critical
+                        alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
+                        alert.runModal()
+                        return
+                    }
                     self.listView.toolMode = .textToolMode
                     toolbarItem.isSelected = !toolbarItem.isSelected
                     self.toolbarController.lastItemBox = toolbarItem