// // KMDocumentModel.swift // PDF Master // // Created by tangchao on 2022/12/7. // import Cocoa class KMDocumentModel: NSObject { private var _documentURL: URL! var documentURL: URL { get { return _documentURL } } private var _document: CPDFDocument? var document: CPDFDocument? { get { return _document } } var isLocked: Bool { get { if (self.document == nil) { return false } return self.document!.isLocked } } var isEncrypt: Bool { get { if (self.document == nil) { return false } return self.document!.isEncrypted } } var pageCount: Int { get { if (self.document == nil) { return 0 } return Int(self.document!.pageCount) } } var password: String { get { if (self.document == nil) { return "" } if (self.document?.password == nil) { return "" } return (self.document?.password)! } } var currentIndex: Int = 0 convenience init(url: URL) { self.init() _documentURL = url _document = CPDFDocument(url: url) } override init() {} public func unlock(_ password: String) -> Bool { if (self.document == nil) { return false } return self.document!.unlock(withPassword: password) } }