|
@@ -368,12 +368,13 @@ class KMConvertBaseWindowController: NSWindowController {
|
|
|
return
|
|
|
}
|
|
|
let outputFolderPath = url!.deletingLastPathComponent().path
|
|
|
- /// MARK: 后续新增证书打包后,需要再优化
|
|
|
-// let filePath = self.getConvertFileSavePath()
|
|
|
- let filePath = self.prePDFView.document.documentURL.path
|
|
|
-// if ((self.prePDFView.document?.write(toFile: filePath))!) {
|
|
|
+ let filePath = self.getConvertFileSavePath()
|
|
|
+ if (FileManager.default.fileExists(atPath: filePath)) {
|
|
|
+ try?FileManager.default.removeItem(atPath: filePath)
|
|
|
+ }
|
|
|
+ if ((self.prePDFView.document?.writeDecrypt(to: URL(fileURLWithPath: filePath)))!) {
|
|
|
|
|
|
-// }
|
|
|
+ }
|
|
|
let convert = KMPDFConvert()
|
|
|
self.convert = convert
|
|
|
convert.outputFolderPath = outputFolderPath
|
|
@@ -391,7 +392,6 @@ class KMConvertBaseWindowController: NSWindowController {
|
|
|
self.progressController?.maxValue = Double(convert.pages.count)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
DispatchQueue.global().async {
|
|
|
KMPDFConvertManager.defaultManager.convert(convert: convert, progress: { index in
|
|
|
DispatchQueue.main.async {
|
|
@@ -399,6 +399,11 @@ class KMConvertBaseWindowController: NSWindowController {
|
|
|
}
|
|
|
}) { [unowned self] finished, error in
|
|
|
self.hiddenProgressWindow()
|
|
|
+
|
|
|
+ // 清除临时文件
|
|
|
+ if (FileManager.default.fileExists(atPath: filePath)) {
|
|
|
+ try?FileManager.default.removeItem(atPath: filePath)
|
|
|
+ }
|
|
|
if finished {
|
|
|
cancelButtonAction()
|
|
|
if FileManager.default.fileExists(atPath: convert.outputFilePath) {
|