Browse Source

【加密】拥有权限密码的文档不能打印 -- 修复

lizhe 10 months ago
parent
commit
91de35590e

+ 2 - 5
PDF Office/PDF Master/Base.lproj/Main.storyboard

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -436,9 +436,6 @@
                                                     </menuItem>
                                                 </items>
                                             </menu>
-                                            <connections>
-                                                <action selector="menuItemAction_print:" target="Ady-hI-5gd" id="qYQ-dN-1l9"/>
-                                            </connections>
                                         </menuItem>
                                     </items>
                                 </menu>

+ 8 - 0
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -186,6 +186,14 @@ class KMPrintWindowController: KMBaseWindowController, NetServiceBrowserDelegate
         }
         
         if inputDocument != nil {
+            if !inputDocument!.allowsCopying || !inputDocument!.allowsPrinting {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
+                alert.runModal()
+                return
+            }
+            
             guard let  pdfDocument = PDFDocument(url: inputDocument!.documentURL) else { return }
         }
         

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

@@ -1446,6 +1446,13 @@ extension KMMainViewController: NSMenuItemValidation, NSMenuDelegate {
             }
             return true
         }
+        
+        if menuItem.action == #selector(menuItemAction_print) {
+            if self.listView.document.permissionsStatus == .user && !self.listView.document.allowsPrinting {
+                return false
+            }
+        }
+        
         guard let action = menuItem.action else {
             return false
         }