Skip to content

Commit ec4a938

Browse files
Merge pull request #1509 from syncfusion-content/848740_Mac_sample
848740 : Need to update UG documentation in OCR section
2 parents 5dd16ba + 46a625b commit ec4a938

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

File-Formats/PDF/Working-with-OCR/MAC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ using (OCRProcessor processor = new OCRProcessor())
7171
By executing the program, you will get a PDF document as follows.
7272
![WPF OCR output screenshot](OCR-Images/Output.png)
7373

74-
A complete working sample can be downloaded from [GitHub](https://github.com/SyncfusionExamples/OCR-csharp-examples/tree/master/WPF).
74+
A complete working sample can be downloaded from [GitHub](https://github.com/SyncfusionExamples/OCR-csharp-examples/tree/master/Mac).
7575

7676
Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net) to explore the rich set of Syncfusion PDF library features.
7777

File-Formats/PDF/Working-with-OCR/Troubleshooting.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,33 @@ If the "brew" is not installed on your machine, you can install it using the fol
204204
//Initialize the OCR processor by providing the path of tesseract binaries.
205205
using (OCRProcessor processor = new OCRProcessor("/opt/homebrew/Cellar/tesseract/5.3.2/lib"))
206206

207+
{% endhighlight %}
208+
<br><br/>
209+
210+
3.Add the TessDataPath from bin folder. Refer to the example code below:
211+
<br></br>
212+
{% highlight c# tabtitle="C#" %}
213+
214+
using (OCRProcessor processor = new OCRProcessor("/opt/homebrew/Cellar/tesseract/5.3.2/lib"))
215+
{
216+
FileStream fileStream = new FileStream("../../../Input.pdf", FileMode.Open, FileAccess.Read);
217+
//Load a PDF document.
218+
PdfLoadedDocument lDoc = new PdfLoadedDocument(fileStream);
219+
//Set OCR language to process.
220+
processor.Settings.Language = Languages.English;
221+
//Process OCR by providing the PDF document.
222+
processor.TessDataPath = "runtimes/tessdata";
223+
processor.PerformOCR(lDoc);
224+
//Create file stream.
225+
using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite))
226+
{
227+
//Save the PDF document to file stream.
228+
lDoc.Save(outputFileStream);
229+
}
230+
//Close the document.
231+
lDoc.Close(true);
232+
}
233+
207234
{% endhighlight %}
208235
</td>
209236
</tr>

0 commit comments

Comments
 (0)