Skip to content

Commit 147132f

Browse files
committed
1043933: Resolved the playground failures
1 parent d06ab91 commit 147132f

2 files changed

Lines changed: 11 additions & 20 deletions

File tree

  • OCR/.NET
    • Perform-OCR-on-PDF-with-multiple-languages/Perform-OCR-on-PDF-with-multiple-languages
    • Perform-OCR-on-image-file/Perform-OCR-on-image-file

OCR/.NET/Perform-OCR-on-PDF-with-multiple-languages/Perform-OCR-on-PDF-with-multiple-languages/Program.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
//Sets Unicode font to preserve the Unicode characters in a PDF document.
1111
processor.UnicodeFont = new PdfTrueTypeFont(Path.GetFullPath(@"Data/ARIALUNI.ttf"), 8);
1212
// Set OCR language
13-
processor.Settings.Language = "eng+deu+ara+ell+fra"; // English, German, Arabic, Greek, French
14-
// Set the path to the Tesseract language data folder
15-
processor.TessDataPath = Path.GetFullPath(@"../../Tessdata");
13+
processor.Settings.Language = "eng+deu+ara+ell"; // English, German, Arabic, Greek
1614
// Perform OCR
17-
processor.PerformOCR(loadedDocument);
15+
processor.PerformOCR(loadedDocument, processor.TessDataPath);
1816
// Save the PDF document
1917
loadedDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
20-
}
18+
}
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
using Syncfusion.OCRProcessor;
22
using Syncfusion.Pdf.Graphics;
3-
using System.Drawing;
4-
5-
string tessdataPath = Path.GetFullPath(@"Tessdata");
63

74
//Initialize the OCR processor by providing the path of the tesseract binaries.
85
using (OCRProcessor processor = new OCRProcessor())
96
{
10-
//Get stream from the image file.
7+
//Get stream from the image file.
118
FileStream stream = new FileStream(Path.GetFullPath(@"Data/Input.jpg"), FileMode.Open);
12-
9+
1310
//Set OCR language to process.
1411
processor.Settings.Language = Languages.English;
15-
12+
1613
//Sets Unicode font to preserve the Unicode characters in a PDF document.
1714
FileStream fontStream = new FileStream(Path.GetFullPath(@"Data/ARIALUNI.ttf"), FileMode.Open);
18-
15+
1916
processor.UnicodeFont = new PdfTrueTypeFont(fontStream, 8);
20-
17+
2118
//Perform the OCR process for an image steam.
22-
string ocrText = processor.PerformOCR(stream, tessdataPath);
23-
24-
//Write the OCR'ed text in text file.
25-
using (StreamWriter writer = new StreamWriter(Path.GetFullPath(@"Output/Output.txt"), true))
26-
{
27-
writer.WriteLine(ocrText);
28-
}
19+
string ocrText = processor.PerformOCR(stream, processor.TessDataPath);
20+
21+
System.IO.File.WriteAllText(Path.GetFullPath(@"Output/Output.txt"), ocrText);
2922
}

0 commit comments

Comments
 (0)