1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // KMPageEditSettingBaseModel.swift
- // PDF Master
- //
- // Created by tangchao on 2023/1/12.
- //
- import Cocoa
- class KMPageEditSettingBaseModel: NSObject {
- var documentURL: URL!
- var password: String = ""
-
- var fileName: String!
- var pathExtension: String!
- var outputFileNameDeletePathExtension: String!
- var outputFileName: String {
- get {
- if (fileName == nil || fileName.isEmpty) {
- return ""
- }
-
- var result: String = ""
- let pathExtension = fileName.components(separatedBy: ".").last
- let files = fileName.split(separator: ".")
- for i in 0 ..< files.count-1 {
- let file: String = String(files[i])
- result.append(file)
- if (i == files.count-2) {
- result.append(".")
- }
- }
-
- return fileName
- }
- }
-
- var pageCount: Int {
- get {
- if (documentURL == nil) {
- return NSNotFound
- }
- documentURL.pathExtension
- let document = CPDFDocument(url: documentURL)
- if (document!.isLocked) {
- if ((document?.unlock(withPassword: password))!) { /// 解锁成功
- return Int(document!.pageCount)
- }
-
- return NSNotFound
- }
-
- return Int(document!.pageCount)
- }
- }
- }
|