OCR throws exception

HI team,


We are using .net 6 core and  syncfusion.pdf.ocr.net.core 21.2.3 .

it is throwing exception when executing this line of code

 var ocrText = processor.PerformOCR(memStream, tessData_Path);

We have tessdata and Tesseract binaries in correct path.


i followed the below post as well still issue not resolved.

https://www.syncfusion.com/forums/181489/pdf-ocr-throw-exception-syncfusion-pdf-pdfexception-exception-has-been-thrown-by-the-target



can you resolve the issue please.


Thanks,

Dayakar.


8 Replies

KS Karmegam Seerangan Syncfusion Team February 23, 2024 09:18 AM UTC

Hi Dayakar,


Thank you for reaching out to Syncfusion support.

We have checked the reported issue on our end and it's working well. We suspect the reported issue may occur due to the missing or mismatched assemblies of Tesseract and tessdata in the runtimes folder. While using the OCR, automatically copies the tesseract assemblies in a runtime folder, and the default assemblies path reference is added in the package itself. you can find the binaries in your project location bin\Debug\netcoreapp3.1\runtimes\. However, we have attached the ASP NET core sample with a manual data path for your reference.

 

Sample:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/OCR-Asp-Net-Core-1536289315

 

Kindly try the sample and let us know the result. If the issue persists, we kindly request you to share the complete code snippet, and environment details (such as OS, RAM, bit version, and culture settings) with us to replicate the same issue on our end. This will be more helpful for us to analyze and provide a prompt solution.


Regards,

Karmegam




AL Ali March 7, 2024 11:36 AM UTC

Hello, when deploying it to Azure App Service I am getting following


Exception has been thrown by the target of an invocation. Failed to find library


The DLL/ binaries are included in the bin/ release folders and it works fine locally.


Any idea what could it be?



KS Karmegam Seerangan Syncfusion Team March 8, 2024 09:57 AM UTC

Hi Ali,


Thank you for reaching out to Syncfusion support.

We have checked the reported issue on our end. The reported issue occurred due to not copying the tessdata assemblies into the Azure environment because, in the latest .NET versions, only the .so, .dly, and .dll files are copied from the runtimes and native folders to the publish folder. The other format files will not be copied to the publish folder, so we have to explicitly copy and set the tessdata folder path from the project directory. Please refer to the screenshot below. However, we have attached a sample for your reference.

 

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Azure-OCR-Processor-Sample1480069247

 

image

 

Kindly try the provided sample and let us know the result.


Regards,

Karmegam




AL Ali March 8, 2024 12:56 PM UTC

I am not sure how to provide sample as it works fine locally. I have tried above but it is reporting the same.

Exception has been thrown by the target of an invocation. Failed to find library


BTW the app targets Dotnet 6 .



AL Ali March 9, 2024 06:05 AM UTC

Do you think it could be that we have a mismatch of these files


Image_8468_1709964284050



KS Karmegam Seerangan Syncfusion Team March 11, 2024 09:11 AM UTC

We are unable to reproduce the reported issue on our end. We can check if the tessdata and Tesseract binaries are properly copied on the Azure environment by using the ls command in the Azure console. Please find the attached screenshot for your reference.

Screenshot 1:

p Search 
App Service plan 
App Service plan 
Quotas 
Change App Service plan 
Development Tools 
Clone 
Console 
Advanced Tools 
c/' App Service Editor (Preview) 
Extensions 
API 
API Management 
API definition 
CORS

 

Screenshot 2:

C : runtimes s 
linux 
tessdata 
Wi a rm64 
win•x64 
win-x86 
c: tessdata 
eng.traineddata

 

Screenshot 3:

C : \site mtimes n - 
leptonica-l 
IibSkiaSharp.dII 
lib SyncfusionTesseract.dll

 

Please confirm that the assemblies have been copied accurately and notify us of the results. If they have not been copied correctly, please ensure proper copying and provide the accurate tessdata and tesseract path in the OCRProcessor class.



AL Ali March 11, 2024 09:49 AM UTC

Here are binaries:


Image_8698_1710150486545


The tess data is in a different location

Image_7535_1710150537155


Does it needs to be in the same directory? We are providing the path respectively... 



KS Karmegam Seerangan Syncfusion Team March 12, 2024 01:47 PM UTC

It is not necessary to include the tessdata path in the same directory. However, the paths must be specified in TessDataPath and TesseractPath in the OCRProcessor class accordingly.

Kindly provide the correct path and let us know the result. If you are still facing issues, we kindly request you to share the modified sample, input documents, package name, package version, and environment details (such as OS, bit version, RAM size, and culture settings) with us to replicate the same issue on our end. It will be more helpful for us to analyze and provide you with a prompt solution.


Loader.
Up arrow icon