|
@@ -15,6 +15,25 @@ class KMSecurityWindowController: KMBaseWindowController {
|
|
|
var batchAction: KMBatchActionBlock?
|
|
|
var doneAction: KMSecurityWindowControllerDoneAction?
|
|
|
|
|
|
+
|
|
|
+ var documentURL: URL? //{
|
|
|
+// didSet{
|
|
|
+// if self.password.count != 0 {
|
|
|
+// self.securityView.documentURL = self.documentURL
|
|
|
+// } else {
|
|
|
+// KMBaseWindowController.checkPassword(url: documentURL, type: .owner) { [unowned self] success, paasswordString in
|
|
|
+// if success {
|
|
|
+// self.securityView.documentURL = self.documentURL
|
|
|
+// } else {
|
|
|
+// guard let callBack = self.itemClick else { return }
|
|
|
+//
|
|
|
+// callBack()
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
override func windowDidLoad() {
|
|
|
super.windowDidLoad()
|
|
|
|
|
@@ -26,7 +45,7 @@ class KMSecurityWindowController: KMBaseWindowController {
|
|
|
securityView.batchAction = { [unowned self] view, files in
|
|
|
if files.count == 0 {
|
|
|
let file: KMFileAttribute = KMFileAttribute()
|
|
|
- file.filePath = self.pdfDocument?.documentURL.path ?? ""
|
|
|
+ file.filePath = self.documentURL?.path ?? self.pdfDocument?.documentURL.path ?? ""
|
|
|
self.batchAction?(self, [file])
|
|
|
} else {
|
|
|
self.batchAction?(self, files)
|
|
@@ -41,12 +60,12 @@ class KMSecurityWindowController: KMBaseWindowController {
|
|
|
|
|
|
extension KMSecurityWindowController {
|
|
|
func setPassword(model: KMSecureEncryptModel, files: [KMFileAttribute]) {
|
|
|
- if pdfDocument == nil {
|
|
|
+ if pdfDocument == nil && documentURL == nil{
|
|
|
guard let filePath = files.first?.filePath else { return }
|
|
|
}
|
|
|
|
|
|
// let myDocument = CPDFDocument(url: NSURL(fileURLWithPath: filePath) as URL)
|
|
|
- if (pdfDocument != nil) {
|
|
|
+ if (pdfDocument != nil || documentURL != nil) {
|
|
|
var options: [CPDFDocumentWriteOption : Any] = [:]
|
|
|
var attribute: [CPDFDocumentAttribute : Any] = [:]
|
|
|
if model.openPasswordOn && model.ownerPasswordOn { /// 开启密码 & 权限密码
|