|
@@ -380,6 +380,27 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
|
|
|
Task { @MainActor in
|
|
|
self.toolBar.unSelectItem(for: KMToolbarPageEditSplitItemIdentifier)
|
|
|
+// if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
|
|
|
+// let _ = KMComparativeTableViewController.show(window: self.view.window!, .pageEdit)
|
|
|
+// return
|
|
|
+// }
|
|
|
+ if await (KMLightMemberManager.manager.canPayFunction() == false) {
|
|
|
+ let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!, isContinue: true, type: .split) { isSubscribeSuccess, isWaterMarkExport, isClose in
|
|
|
+ if (isClose) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (isSubscribeSuccess) {
|
|
|
+ self._showSplitWindow()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (isWaterMarkExport) {
|
|
|
+ self._showSplitWindow(limit: true)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
self._showSplitWindow()
|
|
|
}
|
|
|
}
|
|
@@ -429,73 +450,127 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if self?.canPayFunction == false {
|
|
|
- let _ = KMSubscribeWaterMarkWindowController.show(window: windowController.window!, isContinue: true, type: .split) { isSubscribeSuccess, isWaterMarkExport, isClose in
|
|
|
- var limit = true
|
|
|
- if (isClose) {
|
|
|
- return
|
|
|
- }
|
|
|
- if (isSubscribeSuccess) {
|
|
|
- limit = false
|
|
|
- }
|
|
|
- if (isWaterMarkExport) {
|
|
|
-
|
|
|
- }
|
|
|
+// if self?.canPayFunction == false {
|
|
|
+// let _ = KMSubscribeWaterMarkWindowController.show(window: windowController.window!, isContinue: true, type: .split) { isSubscribeSuccess, isWaterMarkExport, isClose in
|
|
|
+// var limit = true
|
|
|
+// if (isClose) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if (isSubscribeSuccess) {
|
|
|
+// limit = false
|
|
|
+// }
|
|
|
+// if (isWaterMarkExport) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// /// 拆分
|
|
|
+// let outputModel = _windowC.model! as! KMPageEditSplitSettingModel
|
|
|
+// self?.km_endSheet()
|
|
|
+//
|
|
|
+// let panel = NSOpenPanel()
|
|
|
+// panel.canChooseFiles = false
|
|
|
+// panel.canChooseDirectories = true
|
|
|
+// panel.canCreateDirectories = true
|
|
|
+// panel.beginSheetModal(for: (self?.view.window)!) { response in
|
|
|
+// if (response == .cancel) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// let file_indexs = outputModel.getSplitIndexSets
|
|
|
+// if (file_indexs == nil || file_indexs!.count <= 0) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// DispatchQueue.main.async {
|
|
|
+// self?.showProgressWindow(message: NSLocalizedString("Spliting...", comment: ""))
|
|
|
+// self?.progressC?.maxValue = Double(file_indexs!.count)
|
|
|
+// let _document: CPDFDocument = (self?.listView?.document)!
|
|
|
+//
|
|
|
+// let filePath = "\(panel.url!.path)/\(_document.documentURL.deletingPathExtension().lastPathComponent)"
|
|
|
+// let uniqueFilePath = KMTools.getUniqueFilePath(filePath: filePath)
|
|
|
+// // Swift.debugPrint(uniqueFilePath)
|
|
|
+// if (!FileManager.default.fileExists(atPath: uniqueFilePath)) {
|
|
|
+// try?FileManager.default.createDirectory(atPath: uniqueFilePath, withIntermediateDirectories: true)
|
|
|
+// }
|
|
|
+//
|
|
|
+// var filepaths: [String] = []
|
|
|
+// for i in 0 ..< file_indexs!.count {
|
|
|
+// let indexs = file_indexs![i]
|
|
|
+// if (indexs.isEmpty) {
|
|
|
+// continue
|
|
|
+// }
|
|
|
+// let filepath = String(format: "%@/%@.pdf", uniqueFilePath, model.getNewOutputFileName(index: i+1))
|
|
|
+// filepaths.append(filepath)
|
|
|
+//
|
|
|
+// let newDocument = CPDFDocument()
|
|
|
+// newDocument?.importPages(indexs, from: _document, at: 0)
|
|
|
+// self?.progressC?.increment(by: 1.0)
|
|
|
+// if (limit) {
|
|
|
+// let _ = KMTools.saveWatermarkDocument(document: newDocument!, to: URL(fileURLWithPath: filepath))
|
|
|
+// } else {
|
|
|
+// newDocument?.write(to: URL(fileURLWithPath: filepath))
|
|
|
+// }
|
|
|
+// }
|
|
|
+// self?.hiddenProgressWindow()
|
|
|
+// if let _urlString = filepaths.first?.deletingLastPathComponent {
|
|
|
+// NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: _urlString)])
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ /// 拆分
|
|
|
+ let outputModel = _windowC.model! as! KMPageEditSplitSettingModel
|
|
|
+ self?.km_endSheet()
|
|
|
+
|
|
|
+ let panel = NSOpenPanel()
|
|
|
+ panel.canChooseFiles = false
|
|
|
+ panel.canChooseDirectories = true
|
|
|
+ panel.canCreateDirectories = true
|
|
|
+ panel.beginSheetModal(for: (self?.view.window)!) { response in
|
|
|
+ if (response == .cancel) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let file_indexs = outputModel.getSplitIndexSets
|
|
|
+ if (file_indexs == nil || file_indexs!.count <= 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self?.showProgressWindow(message: NSLocalizedString("Spliting...", comment: ""))
|
|
|
+ self?.progressC?.maxValue = Double(file_indexs!.count)
|
|
|
+ let _document: CPDFDocument = (self?.listView?.document)!
|
|
|
|
|
|
- /// 拆分
|
|
|
- let outputModel = _windowC.model! as! KMPageEditSplitSettingModel
|
|
|
- self?.km_endSheet()
|
|
|
+ let filePath = "\(panel.url!.path)/\(_document.documentURL.deletingPathExtension().lastPathComponent)"
|
|
|
+ let uniqueFilePath = KMTools.getUniqueFilePath(filePath: filePath)
|
|
|
+// Swift.debugPrint(uniqueFilePath)
|
|
|
+ if (!FileManager.default.fileExists(atPath: uniqueFilePath)) {
|
|
|
+ try?FileManager.default.createDirectory(atPath: uniqueFilePath, withIntermediateDirectories: true)
|
|
|
+ }
|
|
|
|
|
|
- let panel = NSOpenPanel()
|
|
|
- panel.canChooseFiles = false
|
|
|
- panel.canChooseDirectories = true
|
|
|
- panel.canCreateDirectories = true
|
|
|
- panel.beginSheetModal(for: (self?.view.window)!) { response in
|
|
|
- if (response == .cancel) {
|
|
|
- return
|
|
|
+ var filepaths: [String] = []
|
|
|
+ for i in 0 ..< file_indexs!.count {
|
|
|
+ let indexs = file_indexs![i]
|
|
|
+ if (indexs.isEmpty) {
|
|
|
+ continue
|
|
|
}
|
|
|
+ let filepath = String(format: "%@/%@.pdf", uniqueFilePath, model.getNewOutputFileName(index: i+1))
|
|
|
+ filepaths.append(filepath)
|
|
|
|
|
|
- let file_indexs = outputModel.getSplitIndexSets
|
|
|
- if (file_indexs == nil || file_indexs!.count <= 0) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- DispatchQueue.main.async {
|
|
|
- self?.showProgressWindow(message: NSLocalizedString("Spliting...", comment: ""))
|
|
|
- self?.progressC?.maxValue = Double(file_indexs!.count)
|
|
|
- let _document: CPDFDocument = (self?.listView?.document)!
|
|
|
-
|
|
|
- let filePath = "\(panel.url!.path)/\(_document.documentURL.deletingPathExtension().lastPathComponent)"
|
|
|
- let uniqueFilePath = KMTools.getUniqueFilePath(filePath: filePath)
|
|
|
- // Swift.debugPrint(uniqueFilePath)
|
|
|
- if (!FileManager.default.fileExists(atPath: uniqueFilePath)) {
|
|
|
- try?FileManager.default.createDirectory(atPath: uniqueFilePath, withIntermediateDirectories: true)
|
|
|
- }
|
|
|
-
|
|
|
- var filepaths: [String] = []
|
|
|
- for i in 0 ..< file_indexs!.count {
|
|
|
- let indexs = file_indexs![i]
|
|
|
- if (indexs.isEmpty) {
|
|
|
- continue
|
|
|
- }
|
|
|
- let filepath = String(format: "%@/%@.pdf", uniqueFilePath, model.getNewOutputFileName(index: i+1))
|
|
|
- filepaths.append(filepath)
|
|
|
-
|
|
|
- let newDocument = CPDFDocument()
|
|
|
- newDocument?.importPages(indexs, from: _document, at: 0)
|
|
|
- self?.progressC?.increment(by: 1.0)
|
|
|
- if (limit) {
|
|
|
- let _ = KMTools.saveWatermarkDocument(document: newDocument!, to: URL(fileURLWithPath: filepath))
|
|
|
- } else {
|
|
|
- newDocument?.write(to: URL(fileURLWithPath: filepath))
|
|
|
- }
|
|
|
- }
|
|
|
- self?.hiddenProgressWindow()
|
|
|
- if let _urlString = filepaths.first?.deletingLastPathComponent {
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: _urlString)])
|
|
|
- }
|
|
|
+ let newDocument = CPDFDocument()
|
|
|
+ newDocument?.importPages(indexs, from: _document, at: 0)
|
|
|
+ self?.progressC?.increment(by: 1.0)
|
|
|
+ if (limit) {
|
|
|
+ let _ = KMTools.saveWatermarkDocument(document: newDocument!, to: URL(fileURLWithPath: filepath))
|
|
|
+ } else {
|
|
|
+ newDocument?.write(to: URL(fileURLWithPath: filepath))
|
|
|
}
|
|
|
}
|
|
|
+ self?.hiddenProgressWindow()
|
|
|
+ if let _urlString = filepaths.first?.deletingLastPathComponent {
|
|
|
+ NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: _urlString)])
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|