|
@@ -180,11 +180,12 @@ class KMConvertPDFManager: NSObject {
|
|
|
convertString.append("if not isRun then quit\n")
|
|
|
convertString.append("end tell\n")
|
|
|
|
|
|
- let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
- let docScript = NSAppleScript(source: convertString)
|
|
|
- docScript?.executeAndReturnError(dic)
|
|
|
+// let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
+// let docScript = NSAppleScript(source: convertString)
|
|
|
+// docScript?.executeAndReturnError(dic)
|
|
|
+ let dic = KMOCTool.convertOfficeFile(toPdf: convertString)
|
|
|
DispatchQueue.main.async {
|
|
|
- completionHandler(true, dic?.pointee)
|
|
|
+ completionHandler(true, dic as NSDictionary)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -239,11 +240,12 @@ class KMConvertPDFManager: NSObject {
|
|
|
convertString.append("close active presentation\n")
|
|
|
convertString.append("end tell\n")
|
|
|
|
|
|
- let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
- let docScript = NSAppleScript(source: convertString)
|
|
|
- docScript?.executeAndReturnError(dic)
|
|
|
+// let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
+// let docScript = NSAppleScript(source: convertString)
|
|
|
+// docScript?.executeAndReturnError(dic)
|
|
|
+ let dic = KMOCTool.convertOfficeFile(toPdf: convertString)
|
|
|
DispatchQueue.main.async {
|
|
|
- completionHandler(true, dic?.pointee)
|
|
|
+ completionHandler(true, dic as NSDictionary)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -275,7 +277,22 @@ class KMConvertPDFManager: NSObject {
|
|
|
|
|
|
class func convertExcelPath(_ filePath: String, savePath: String, completionHandler: @escaping ((Bool, NSDictionary?) -> Void)) {
|
|
|
DispatchQueue.global().async {
|
|
|
- let dic = KMOCTool.convertExcel(toPdfFilePath: filePath, savePath: savePath)
|
|
|
+ var convertString = String(format: "set filePath to\"%@\"\n", filePath)
|
|
|
+ convertString = convertString.appendingFormat("set savePath to \"%@\"\n", savePath)
|
|
|
+ convertString.append("set tFile to (POSIX path of filePath) as POSIX file\n")
|
|
|
+ convertString.append("tell application \"Microsoft Excel\"\n")
|
|
|
+ convertString.append("set isRun to running\n")
|
|
|
+ convertString.append("set wkbk1 to open workbook workbook file name tFile\n")
|
|
|
+ convertString.append("alias savePath\n")
|
|
|
+ convertString.append("save workbook as wkbk1 filename savePath file format PDF file format with overwrite\n")
|
|
|
+ convertString.append("close wkbk1 saving no\n")
|
|
|
+ convertString.append("if not isRun then quit\n")
|
|
|
+ convertString.append("end tell\n")
|
|
|
+
|
|
|
+// let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
+// let docScript = NSAppleScript(source: convertString)
|
|
|
+// docScript?.executeAndReturnError(dic)
|
|
|
+ let dic = KMOCTool.convertOfficeFile(toPdf: convertString)
|
|
|
DispatchQueue.main.async {
|
|
|
completionHandler(true, dic as NSDictionary)
|
|
|
}
|
|
@@ -294,11 +311,12 @@ class KMConvertPDFManager: NSObject {
|
|
|
convertString.append("if not isRun then quit\n")
|
|
|
convertString.append("end tell")
|
|
|
|
|
|
- let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
- let docScript = NSAppleScript(source: convertString)
|
|
|
- docScript?.executeAndReturnError(dic)
|
|
|
+// let dic: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
|
|
|
+// let docScript = NSAppleScript(source: convertString)
|
|
|
+// docScript?.executeAndReturnError(dic)
|
|
|
+ let dic = KMOCTool.convertOfficeFile(toPdf: convertString)
|
|
|
DispatchQueue.main.async {
|
|
|
- completionHandler(true, dic?.pointee)
|
|
|
+ completionHandler(true, dic as NSDictionary)
|
|
|
}
|
|
|
}
|
|
|
}
|