Browse Source

【2025】【OCR】page OCR进度条补充

lizhe 2 months ago
parent
commit
83b94e5ab6

+ 1 - 1
PDF Office/PDF Master/Class/Common/OC/OCR/KMGOCRManager.m

@@ -439,7 +439,7 @@ static inline NSFont * FontWithSize(NSString *strChar, CGSize size) {
                                                (result.textBounds.size.width)/newScale,
                                                (result.textBounds.size.height)/newScale);
                     NSDictionary *dic = @{NSFontAttributeName:FontWithSize(result.text, CGSizeMake(result.textBounds.size.width/newScale, result.textBounds.size.height/newScale)),
-                                          NSForegroundColorAttributeName:[NSColor blackColor]};
+                                          NSForegroundColorAttributeName:[NSColor clearColor]};
                     [result.text drawInRect:bounds withAttributes:dic];
                 }
             }

+ 5 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -3158,14 +3158,17 @@ extension KMMainViewController {
             model.pageRange = [self.listView.currentPageIndex]
         }
         
-        KMOCRManager.manager.convertOCR(document: document, model: model, progress: { progress in
-            
+        self.showProgressWindow(message: "正在转换中....")
+        KMOCRManager.manager.convertOCR(document: document, model: model, progress: { [weak self] progress in
+            self?.progressC?.message = "正在转换中...."
+            self?.progressC?.doubleValue = Double(progress * 100)
         }) { [weak self] document, text, error  in
 //            self?.view.window?.windowController.endLoading()
 //            window.km_quick_endSheet()
             if !model.saveAsPDF {
                 self?.listView.layoutDocumentView()
             }
+            self?.hiddenProgressWindow()
         }
     }
     

+ 2 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/OCR/Tool/Manager/KMOCRManager.swift

@@ -267,6 +267,8 @@ extension KMOCRManager: KMGOCRManagerDelegate {
         }
         self.dealWithResults(results, OCRImageAtIndex: pageIndex)
         print("进度 :\(Float(index) / Float(self.pageIndexs.count))")
+        let progressValue = (Float(index) / Float(self.pageIndexs.count))
+        self.progress?(progressValue)
     }
     
     func gocrManager(_ manager: KMGOCRManager!, didFailureOCRImageAt index: Int, error: Error!) {