12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // KMDocumentModel.swift
- // PDF Reader Pro
- //
- // 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)
- }
- }
|