Browse Source

[图片转PDF] - 优化

liujiajie 1 year ago
parent
commit
53fa449611
1 changed files with 5 additions and 5 deletions
  1. 5 5
      PDF Office/PDF Master/Class/Batch/Tools/KMImageToPDFMethod.swift

+ 5 - 5
PDF Office/PDF Master/Class/Batch/Tools/KMImageToPDFMethod.swift

@@ -154,11 +154,11 @@ class KMImageToPDFMethod: NSObject, KMGOCRManagerDelegate {
             return
         }
         let filePath: String = photoArray?[convertIndex] as! String
-        var savePath = path
+        let savePath = path
         var isDir: ObjCBool = false
         if FileManager.default.fileExists(atPath: filePath , isDirectory: &isDir) && !isDir.boolValue {
             let model = KMImageModel(filepath: filePath )
-            let tString = model.photoName.deletingPathExtension
+            let tString = model.photoName.deletingPathExtension.lastPathComponent//model.photoName.deletingPathExtension
             
             var newpath = path.stringByAppendingPathComponent(tString).stringByAppendingPathExtension("pdf")
             newpath = getUniqueFilePath(newpath)
@@ -169,10 +169,10 @@ class KMImageToPDFMethod: NSObject, KMGOCRManagerDelegate {
                 _ = pdf?.km_insertPage(imag.size, withImage: filePath , at: pdf?.pageCount ?? 0)
             }
             
-            DispatchQueue.global().async {
+//            DispatchQueue.global().async {
                 var isSucceed = false
                 
-                isSucceed = ((pdf?.write(toFile: path)) != nil)
+                isSucceed = ((pdf?.write(toFile: newpath)) != nil)
                 var pre: Float = 0
                 if self.photoArray?.count ?? 0 > 0{
                     pre = Float(self.convertIndex + 1) / Float(self.photoArray?.count ?? 1)
@@ -196,7 +196,7 @@ class KMImageToPDFMethod: NSObject, KMGOCRManagerDelegate {
                         complete(path, self.errorArray as! Array<Any>, self.errorOCRArray as! Array<Any>)
                     }
                 }
-            }
+//            }
             
         } else {
             if convertIndex < (photoArray?.count ?? 0) - 1 {