|
@@ -96,6 +96,15 @@ class KMAIOpenPDFFilesVC: NSViewController {
|
|
|
let imageName = NSString(string: NSString(string: filePath).lastPathComponent).deletingPathExtension
|
|
|
|
|
|
let path = self.fetchDifferentFilePath(filePath: savePath + "/" + imageName + ".pdf")
|
|
|
+
|
|
|
+ if (!FileManager.default.fileExists(atPath: path.deletingLastPathComponent as String)) {
|
|
|
+ try?FileManager.default.createDirectory(atPath: path.deletingLastPathComponent as String, withIntermediateDirectories: true, attributes: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!FileManager.default.fileExists(atPath: path as String)) {
|
|
|
+ FileManager.default.createFile(atPath: path as String, contents: nil)
|
|
|
+ }
|
|
|
+
|
|
|
let document = CPDFDocument.init()
|
|
|
var success = false
|
|
|
|
|
@@ -133,6 +142,15 @@ class KMAIOpenPDFFilesVC: NSViewController {
|
|
|
let filePath = url.path
|
|
|
let folderPath = "convertToPDF.pdf"
|
|
|
let savePath = folderPath.kUrlToPDFFolderPath()
|
|
|
+
|
|
|
+ if (!FileManager.default.fileExists(atPath: savePath!.deletingLastPathComponent as String)) {
|
|
|
+ try?FileManager.default.createDirectory(atPath: savePath!.deletingLastPathComponent as String, withIntermediateDirectories: true, attributes: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!FileManager.default.fileExists(atPath: savePath! as String)) {
|
|
|
+ FileManager.default.createFile(atPath: savePath! as String, contents: nil)
|
|
|
+ }
|
|
|
+
|
|
|
if savePath == nil {
|
|
|
return
|
|
|
}
|
|
@@ -371,6 +389,13 @@ class KMAIOpenPDFFilesVC: NSViewController {
|
|
|
@IBAction func openBlankPage(_ sender: Any) {
|
|
|
let fileName: NSString = String(format: "%@.pdf", NSLocalizedString("Untitled", comment: "")) as NSString
|
|
|
let savePath = fetchUniquePath(fileName.kUrlToPDFFolderPath())
|
|
|
+ if (!FileManager.default.fileExists(atPath: savePath.deletingLastPathComponent as String)) {
|
|
|
+ try?FileManager.default.createDirectory(atPath: savePath.deletingLastPathComponent as String, withIntermediateDirectories: true, attributes: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!FileManager.default.fileExists(atPath: savePath as String)) {
|
|
|
+ FileManager.default.createFile(atPath: savePath as String, contents: nil)
|
|
|
+ }
|
|
|
let pdfDocument = CPDFDocument()
|
|
|
pdfDocument?.insertPage(CGSize(width: 595, height: 842), at: 0)
|
|
|
pdfDocument?.write(to: URL(fileURLWithPath: savePath))
|