marinofaggiana 5 vuotta sitten
vanhempi
commit
fb0020fd5e

+ 48 - 49
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -413,34 +413,30 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate {
         }
         
         // Text Recognition TXT
-        if NCBrandOptions.sharedInstance.useMLVision {
-            let rowTextRecognition: XLFormRowDescriptor = self.form.formRow(withTag: "textRecognition")!
-        
-            if rowTextRecognition.value as! Int == 1 && fileType == "TXT" {
+        if fileType == "TXT" && NCBrandOptions.sharedInstance.useMLVision && self.form.formRow(withTag: "textRecognition")!.value as! Int == 1 {
+            
+            var textFile = ""
+            
+            for image in self.arrayImages {
                 
-                var textFile = ""
+                guard let features = self.textDetector?.features(in: image, options: nil) as? [GMVTextBlockFeature] else {
+                    continue
+                }
                 
-                for image in self.arrayImages {
+                for textBlock in features {
                     
-                    guard let features = self.textDetector?.features(in: image, options: nil) as? [GMVTextBlockFeature] else {
+                    guard let text = textBlock.value else {
                         continue
                     }
                     
-                    for textBlock in features {
-                        
-                        guard let text = textBlock.value else {
-                            continue
-                        }
-                        
-                        textFile = textFile + text + "\n\n"
-                    }
-                    
-                    do {
-                        try textFile.write(to: NSURL(fileURLWithPath: fileNameGenerateExport) as URL  , atomically: true, encoding: .utf8)
-                    } catch {
-                        self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
-                        return
-                    }
+                    textFile = textFile + text + "\n\n"
+                }
+                
+                do {
+                    try textFile.write(to: NSURL(fileURLWithPath: fileNameGenerateExport) as URL  , atomically: true, encoding: .utf8)
+                } catch {
+                    self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
+                    return
                 }
             }
         }
@@ -456,38 +452,41 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate {
             }
             let context = UIGraphicsGetCurrentContext()
             
-            for image in self.arrayImages {
-                
-                UIGraphicsBeginPDFPageWithInfo(CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height), nil)
-                UIImageView.init(image:image).layer.render(in: context!)
+            for var image in self.arrayImages {
                 
-                // Text Recognition
-                if NCBrandOptions.sharedInstance.useMLVision {
-                    let rowTextRecognition: XLFormRowDescriptor = self.form.formRow(withTag: "textRecognition")!
+                if NCBrandOptions.sharedInstance.useMLVision && self.form.formRow(withTag: "textRecognition")!.value as! Int == 1 {
                     
-                    if rowTextRecognition.value as! Int == 1 {
-                        if let features = self.textDetector?.features(in: image, options: nil) as? [GMVTextBlockFeature] {
-                            for textBlock in features {
-                                for textLine in textBlock.lines {
-                                    
-                                    let bounds = textLine.bounds
-                                    let text = textLine.value!
-                                    var fontColor = UIColor.clear
-                                    
-#if targetEnvironment(simulator)
-                                    fontColor = UIColor.red
-#endif
-                                    
-                                    //print(text)
-                                    
-                                    let font = UIFont.systemFont(ofSize: bounds.size.height, weight: .regular)
-                                    let bestFittingFont = NCUtility.sharedInstance.bestFittingFont(for: text, in: bounds, fontDescriptor: font.fontDescriptor)
-                                    
-                                    text.draw(in: bounds, withAttributes: [NSAttributedString.Key.font: bestFittingFont, NSAttributedString.Key.foregroundColor: fontColor])
-                                }
+                    UIGraphicsBeginPDFPageWithInfo(CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height), nil)
+                    UIImageView.init(image:image).layer.render(in: context!)
+                    
+                    if let features = self.textDetector?.features(in: image, options: nil) as? [GMVTextBlockFeature] {
+                        for textBlock in features {
+                            for textLine in textBlock.lines {
+                                
+                                let bounds = textLine.bounds
+                                let text = textLine.value!
+                                var fontColor = UIColor.clear
+                                
+                                #if targetEnvironment(simulator)
+                                fontColor = UIColor.red
+                                #endif
+                                
+                                //print(text)
+                                
+                                let font = UIFont.systemFont(ofSize: bounds.size.height, weight: .regular)
+                                let bestFittingFont = NCUtility.sharedInstance.bestFittingFont(for: text, in: bounds, fontDescriptor: font.fontDescriptor)
+                                
+                                text.draw(in: bounds, withAttributes: [NSAttributedString.Key.font: bestFittingFont, NSAttributedString.Key.foregroundColor: fontColor])
                             }
                         }
                     }
+                    
+                } else {
+                    
+                    image = changeImageFromQuality(image, dpiQuality: dpiQuality)
+                    
+                    UIGraphicsBeginPDFPageWithInfo(CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height), nil)
+                    UIImageView.init(image:image).layer.render(in: context!)
                 }
             }
             

+ 2 - 0
iOSClient/Networking/NCService.swift

@@ -286,6 +286,7 @@ class NCService: NSObject {
                 }
                 
                 // Get Trash List
+                /*
                 let pathTrash = k_dav + "/trashbin/" + (self.appDelegate.activeUserID as NSString).addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlFragmentAllowed)! + "/trash/"
                 
                 OCNetworking.sharedManager().listingTrash(withAccount: account, path: pathTrash, serverUrl: self.appDelegate.activeUrl, depth: "infinity", completion: { (account, item, message, errorCode) in
@@ -296,6 +297,7 @@ class NCService: NSObject {
                         }
                     }
                 })
+                */
                 
                 // Get Handwerkcloud
                 if (capabilities!.isHandwerkcloudEnabled) {