Spire.OCR for .NET is a professional OCR library to read text from Images in JPG, PNG, GIF, BMP and TIFF formats within .NET platforms

Sun Dec 31, 2023 5:20 am

Hello,
I'm using Spire.OCR 1.9.2 version to extract data from a scanned image.
I could not get any data from the scanned image. I used the below code,
Code: Select all
   // Create an OcrScanner object
      OcrScanner scanner = new OcrScanner();
      // Set the dependency file path for the OcrScanner object
      scanner.setDependencies(dependencies);

      // Use the OcrScanner object to scan the specified image file
      scanner.scan(FILE_PATH);

      // Get the scanned text content
      String scannedText = scanner.getText().toString();

      // Create an output file object
      File output = new File(OUTPUT_FILE_PATH);
      // If the output file already exists, delete it
      if (output.exists()) {
         output.delete();
      }
      // Create a BufferedWriter object to write content to the output file
      BufferedWriter writer = new BufferedWriter(new FileWriter(OUTPUT_FILE_PATH));
      // Write the scanned text content to the output file
      writer.write(scannedText);
      // Close the BufferedWriter object to release resources
      writer.close();


PDF-or-TIFF-Datamation.jpg


I have converted the scanned image content into a PDF file using Spire products like the one below.
Code: Select all
   // Create a PDF document
      PdfDocument pdf = new PdfDocument();
      // Add a new page
      PdfPageBase page = pdf.getPages().add();

      // Load the image
      PdfImage image = PdfImage.fromFile(FILE_PATH);

      double widthFitRate = image.getPhysicalDimension().getWidth() / page.getCanvas().getClientSize().getWidth();
      double heightFitRate = image.getPhysicalDimension().getHeight() / page.getCanvas().getClientSize().getHeight();
      double fitRate = Math.max(widthFitRate, heightFitRate);

      // get the picture width and height
      double fitWidth = image.getPhysicalDimension().getWidth() / fitRate;
      double fitHeight = image.getPhysicalDimension().getHeight() / fitRate;

      // Draw image
      page.getCanvas().drawImage(image, 0, 30, fitWidth, fitHeight);

      // Save document to file
      pdf.saveToFile(OUTPUT_FILE_PATH);
      pdf.close();


After converting the image into a PDF file, I tried to scan the data from this PDF file. In this, the table has solid lines. But no table has been identified.

Please guide how can I extract scanned content.

Usha.Thavasiappan
 
Posts: 40
Joined: Mon Nov 06, 2023 8:16 am

Tue Jan 02, 2024 3:29 am

Hello,

Thank you for your inquiry.
I have tested the image you provided using Spire.OCR for Java Version: 1.9.2, and it was able to extract the text. However, I noticed that some of the text was missing. I have submitted this issue to our development team for investigation and resolution. The problem has been assigned the reference number SPIREOCR-48.
I have attached the project I used for testing, which includes the result file. Please download and test it on your end.
Additionally, regarding your mention of converting the image to a PDF document and extracting text from it, please note that for image-based PDFs, the text extraction functionality in Spire.Pdf does not work effectively.
We apologize for any inconvenience caused by these issues. Our team is actively working on resolving them, and we appreciate your patience. If you have any further questions or concerns, please don't hesitate to let me know.


Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Tue Jan 02, 2024 5:01 am

Hello,
Yes, I could also get improper data and not extract full content.
Thanks for considering this as a bug.

Is it possible to improve the image-based PDF data extraction?

Usha.Thavasiappan
 
Posts: 40
Joined: Mon Nov 06, 2023 8:16 am

Tue Jan 02, 2024 5:49 am

Hello,

Thank you for your feedback.
Regarding the issue SPIREOCR-48, I want to assure you that as soon as our development team resolves this problem, I will notify you promptly.
Furthermore, concerning the extraction of text from scanned PDF documents, I have added this feature to our upgrade list with the reference number SPIREPDF-6474. Rest assured that we will inform you in a timely manner once this functionality is implemented in the future.
We value your patience and understanding as we work towards improving our product. If you have any further questions or concerns, please feel free to reach out to me.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Feb 26, 2024 12:21 pm

Hello,
Please update the current status of the below bugs.
SPIREOCR-48
SPIREPDF-6474

Usha.Thavasiappan
 
Posts: 40
Joined: Mon Nov 06, 2023 8:16 am

Tue Feb 27, 2024 3:25 am

Hello,

Thank you for your follow-up.

We regret to inform you that the issues SPIREOCR-48 and SPIREPDF-6474 are still not fully resolved due to their complexity. Our development team is actively investigating and working towards a solution. We kindly ask for your patience as we continue to address these challenges.

We understand the importance of resolving these issues promptly and assure you that we are dedicated to finding a resolution as soon as possible. Your understanding and cooperation during this process are greatly appreciated.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Mar 03, 2025 7:03 am

Hello,
Can I have an update for the bugs SPIREOCR-48 and SPIREPDF-6474?

Usha.Thavasiappan
 
Posts: 40
Joined: Mon Nov 06, 2023 8:16 am

Tue Mar 04, 2025 2:41 am

Hello,

Thank you for your follow-up.
Sorry, due to the complexity of these issues, they are still being processed. At present, our Spire.OCR product is mainly used to extract text content from images, and does not support table recognition. The order of text extraction is generally from top to bottom. After extracting text, Spire.OCR can also return a collection of TextBlocks corresponding to the result, which contains the coordinate information of the text. If you want to keep the structure and order of the table, you can sort and organize these coordinate information to achieve a text arrangement that is more in line with the table logic. Sorry, we are unable to provide a more general sorting algorithm at present. Hope you can understand.
Code: Select all
for (IOCRTextBlock block : scanner.getText().getBlocks()) {
    String text = block.getText();
    Rectangle2D box = block.getBox();
    System.out.println(text + "position x: "+box.getX() +"position y:"+ box.getY());
    // TODO  add sorting algorithm
}


Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 762
Joined: Mon Dec 27, 2021 2:23 am

Tue Mar 04, 2025 5:09 am

Hello,
Hmm.. This will not fulfil my requirements. It is not very easy to sort and process every single text detection. In the image attached to this thread if a cell data has multiple lines of text, each line consumes different text extraction. Also, many spaces are not identified correctly in a sentence.

Will this OCR extract content from scanned PDF files?

Usha.Thavasiappan
 
Posts: 40
Joined: Mon Nov 06, 2023 8:16 am

Tue Mar 04, 2025 5:40 am

Hello,

Thanks for your quick reply.
we haven't found a suitable solution to meet your needs at this time. We will investigate further and notify you if we find one.
Our Spire.OCR does not support extracting content from PDF. As a suggestion, you can convert PDF to images first, and then use Spire.OCR to extract.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 762
Joined: Mon Dec 27, 2021 2:23 am

Tue Mar 04, 2025 8:54 am

Hey,
Even when converting PDF pages into images, the content will be extracted with minimal data accuracy. This will not fit my case right now.
Please let me know once if OCR has any enhancements.
Thanks for your support.

Usha.Thavasiappan
 
Posts: 40
Joined: Mon Nov 06, 2023 8:16 am

Tue Mar 04, 2025 9:25 am

Hello,

Thansk for your reply.
Once there is any major update to our Spire.OCR, I will inform you in time. Thank you for your understanding.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 762
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.OCR

cron