123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // 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)!
- }
- }
-
- 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)
- }
- }
|