|
@@ -584,11 +584,37 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
if (response == .cancel) {
|
|
if (response == .cancel) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- KMPageEditTools.split((self?.listView?.document)!, outputModel, panel.url!.path, outputModel.outputFileNameDeletePathExtension) { result, outputFilepaths, error in
|
|
|
|
- if (result) {
|
|
|
|
- if let _urlString = outputFilepaths?.first?.deletingLastPathComponent {
|
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: _urlString)])
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ 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)"
|
|
|
|
+ if (!FileManager.default.fileExists(atPath: filePath)) {
|
|
|
|
+ try?FileManager.default.createDirectory(atPath: filePath, withIntermediateDirectories: true)
|
|
|
|
+ }
|
|
|
|
+ let fileName = outputModel.outputFileNameDeletePathExtension
|
|
|
|
+
|
|
|
|
+ var filepaths: [String] = []
|
|
|
|
+ for i in 0 ..< file_indexs!.count {
|
|
|
|
+ let indexs = file_indexs![i]
|
|
|
|
+ let filepath = String(format: "%@/%@ %d.pdf", filePath, fileName!, i+1)
|
|
|
|
+ filepaths.append(filepath)
|
|
|
|
+
|
|
|
|
+ let newDocument = CPDFDocument()
|
|
|
|
+ newDocument?.importPages(indexs, from: _document, at: 0)
|
|
|
|
+ self?.progressC?.increment(by: 1.0)
|
|
|
|
+ newDocument?.write(to: URL(fileURLWithPath: filepath))
|
|
|
|
+ }
|
|
|
|
+ self?.hiddenProgressWindow()
|
|
|
|
+ if let _urlString = filepaths.first?.deletingLastPathComponent {
|
|
|
|
+ NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: _urlString)])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|