We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF to Word Converter with OCR in VB.NET

Hi, Support:

I am interested in PDF to Word Converter with OCR. Would you please tell me how to OCR a PDF and then export it as a DOC/Word file in VB.NET and Aspose.PDF for .NET v21.8 or Aspose.OCR for .NET v21.8?

Thanks.

@ducaisoft

You can use both Aspose.PDF and Aspose.OCR in order to create PDF to Word Converter with OCR ability in VB.NET. Please consider using the below code snippet after converting it into VB.NET and let us know in case you face any issue:

// PDF to Word Converter with OCR
string file = dataDir + "input.pdf";
Document pdfDocument = new Document(file);

foreach (Page page in pdfDocument.Pages)
{
 Aspose.Pdf.Devices.PngDevice pngDevice = new Aspose.Pdf.Devices.PngDevice(new Aspose.Pdf.Devices.Resolution(300));
 pngDevice.Process(page, dataDir + "output" + page.Number + ".jpg");
 Aspose.OCR.AsposeOcr libOcr = new Aspose.OCR.AsposeOcr();

 OCR.RecognitionResult slResult = libOcr.RecognizeImage(dataDir + "output" + page.Number + ".jpg", new OCR.RecognitionSettings());
 slResult.Save(dataDir + "results.docx", OCR.SaveFormat.Docx);
}

Thanks for your code snippet, however, it still does not work in my end.
the following information may be for you to investigate this issue:
The Aspose.OCR.dll is version 21.7 and netstandard2.0
The DEV is VS 2017,VB.net, Net 4.6.1.
the code and error as follow:

1.png (30.6 KB)

2.png (37.2 KB)
How to let it work in my end and DEV?
Thanks for your help.

@ducaisoft

It seems like the dependencies for Aspose.OCR were not installed in your project. Please make sure to use .NET Framework higher than 4.6.2 as well as debugging mode as x64 (Not AnyCPU or x86). Please reinstall the Aspose.OCR after changing the .NET Framework and Debug Mode and try again. If you still face any issue, please share your sample PDF with us so that we can test the scenario in our environment and address it accordingly.

Thanks for your suggestion.
I test it as you said:
Install the Net 4.6.2 and as x64 debugging mode, the same exception still there.
Does this dll must run at Net 4.7,4.8 or even higher such as 5.0?

My OS cannot be installed the Net 4.7,it only support at most Net4.6.2.
What’s wrong?

@ducaisoft

The minimum supported .NET framework version by the API is 4.6.2. Also, please make sure that you have not selected the Ignore Dependencies for Dependency behavior in the options Install and Update options on the nuget package manager UI. In case issue still persists, please share following information with us:

  • OS Name and Version
  • Visual Studio Name and Version

The issue is still pending.
The Net version is 4.7:

11.png (31.4 KB)
The debug mode is x64:

22.png (57.5 KB)
The Dll version is 21.7:

33.png (40.0 KB)

The same issue is still there:

44.png (28.4 KB)

  • OS Name and Version:

    55.png (6.5 KB)

  • Visual Studio Name and Version:
    Visual Studio Professional 2017

@ducaisoft

We have logged an investigation ticket as OCRNET-415 in our issue tracking system to further investigate this matter. Please note that we have already tried to reproduce the issue in both VS 2017 and 2019 but we were unable to do so. We will further try to check this case in different environment and under different settings and let you know as soon as the ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

@ducaisoft

Can you please try to use the latest available version of Aspose.OCR for .NET and let us know in case you still notice any issues?

I try the Aspose.OCR V22.1 on VS2017 on win10 based on Net 4.7 and x64, there still throws error like this:

Please investigate what’s wrong for it.

@ducaisoft

Can you please make sure that you have installed below specific versions of the dependencies?

  • onnxruntime 1.7
  • and Aspose.Drawing 4.7**

Nothing installed.
Please provide me the donwload urls for them.
Thanks.

@ducaisoft

You can download them via NuGet Package Manager in Visual Studio 2017/2019. Please also try to install Aspose.OCR for .NET via NuGet Package Manager. In case you still notice any issue, please let us know.