@@ -24,19 +24,11 @@ namespace WinForms_TextExtractionByOCR
24
24
/// </summary>
25
25
public partial class PdfViewer : UserControl
26
26
{
27
- string file ;
28
- string tessaractBinariesPath ;
29
- string tessDataPath ;
30
27
RectangleF bounds ;
31
28
public PdfViewer ( )
32
29
{
33
30
InitializeComponent ( ) ;
34
- #if NETCOREAPP
35
- file = "../../../Data/F#.pdf" ;
36
- #else
37
- file = "../../Data/F#.pdf" ;
38
- #endif
39
- pdfViewer . Load ( file ) ;
31
+ pdfViewer . Load ( "../../Data/F#.pdf" ) ;
40
32
}
41
33
42
34
private void Rectangle_Click ( object sender , RoutedEventArgs e )
@@ -49,23 +41,16 @@ private void PdfViewer_ShapeAnnotationChanged(object sender, Syncfusion.Windows.
49
41
{
50
42
if ( e . Action == Syncfusion . Windows . PdfViewer . AnnotationChangedAction . Add )
51
43
{
52
- #if NETCOREAPP
53
- tessaractBinariesPath = "../../../Tesseract binaries" ;
54
- tessDataPath = @"../../../Tessdata/" ;
55
- #else
56
- tessaractBinariesPath = "../../Tesseract binaries" ;
57
- tessDataPath = @"../../Tessdata/" ;
58
- #endif
59
44
bounds = e . NewBounds ;
60
45
PdfLoadedDocument loadedDocument = pdfViewer . LoadedDocument ;
61
- using ( OCRProcessor processor = new OCRProcessor ( tessaractBinariesPath ) )
46
+ using ( OCRProcessor processor = new OCRProcessor ( "../../Tesseract binaries" ) )
62
47
{
63
48
//Language to process the OCR
64
49
processor . Settings . Language = Languages . English ;
65
50
Bitmap image = GetBitmap ( pdfViewer . ExportAsImage ( pdfViewer . CurrentPageIndex - 1 ) ) ;
66
51
using ( Bitmap clonedImage = image . Clone ( bounds , System . Drawing . Imaging . PixelFormat . Format32bppArgb ) )
67
52
{
68
- string ocrText = processor . PerformOCR ( clonedImage , tessDataPath ) ;
53
+ string ocrText = processor . PerformOCR ( clonedImage , @"../../Tessdata/" ) ;
69
54
}
70
55
image . Dispose ( ) ;
71
56
}
0 commit comments