I am trying to perform ocr a PDF Document using Syncfusion.PDF.OCR.NET with .NET 6 running on windows but it throws the following exception.
Syncfusion.Pdf.PdfException: 'Syncfusion.Pdf.PdfException: Exception has been thrown by the target of an invocation.
at Syncfusion.OCRProcessor.OCRProcessor.ProcessOCR(String args, String imagePathList)
at Syncfusion.OCRProcessor.OCRProcessor.GetHOCR(String imagePath, String dataPath, Boolean multiPageTiff, String imagePathList)
at Syncfusion.OCRProcessor.OCRProcessor.PerformOCR(PdfLoadedDocument lDoc, Int32 startIndex, Int32 endIndex, String dataPath)'
I'm using Syncfusion.PDF.OCR.Net.Core 18.104.22.168
and this is my code.
using (var outputPdf = new FileStream(fileOcrFullPath, FileMode.Create, FileAccess.ReadWrite))
using (var pdfFile = new FileStream(pdfPath, FileMode.Open, FileAccess.Read))
using (OCRProcessor processor = new OCRProcessor(@"TesseractBinaries/Windows"))
PdfLoadedDocument pdf = new PdfLoadedDocument(pdfFile);
processor.Settings.Language = Languages.English;
I'm using indonesia trained data from tesseract.
Thanks in advance.
The reported exception may occurs due to missing or mismatch assemblies of the Tesseract binaries and Tesseract data from OCR processor or the VC++ 2015 redistributable files are missing in the machine, where the OCR processor takes place. So, we need to install the VC++ 2015 redistributable files in your machine.
Please select both vc_redist.x64.exe or x86.exe and install it.
Please find the download link Visual C++ 2015 Redistributable file,
Please find the below documentation page
If still you have facing an error,we request you to share the modified sample,input document to check this on our end.So that it will be helpful for us to analyze and assist you further on this.
But in error log of Visual C++ 2015 appear
[A0AC:4940][2023-05-06T11:49:34]e000: Error 0x80070666: Cannot install a product when a newer version is installed.
Could you please copy and paste the below files to this (C:\Windows\SysWOW64) location, try the OCR process, and let us know the result?
Download and extract the files.
Paste the files in the C:\Windows\SysWOW64 folder.
Check out the OCR process.
Please let us know if you need any further assistance in this.