Browse our Products

Aspose.OCR for Java 21.1 - Release Notes

All Features

KeySummaryCategory
OCRJAVA-95Implement possibility to get result in .doc and .txt formatsEnhancement
OCRJAVA-101Fix bug with length of result linesBug Fixes

Enhancements

The next opportunities:

  • added ability to save the recognition result in the plain text, Microsoft Word, Office Open XML or ODF Text Document format

Public API and Backwards Incompatible Changes

New API

- added method save to the RecognitionResult object

Removed APIs

All methods of the previous release are supported.

Will be deprecated

String RecognizePage(String fullPath, Rectangle box);

String RecognizePage(BufferedImage image_, Rectangle box);

Usage Example

import static java.lang.System.out;

import java.awt.Rectangle;
import java.io.IOException;

import com.aspose.ocr.AsposeOCR;
import com.aspose.ocr.License;
import com.aspose.ocr.RecognitionResult;
import com.aspose.ocr.RecognitionSettings;
import com.aspose.ocr.SaveFormat.Format;

////  for gpu version

// import com.aspose.ocr.gpu.AsposeOCR;
// import com.aspose.ocr.gpu.License;
// import com.aspose.ocr.gpu.RecognitionResult;
// import com.aspose.ocr.gpu.RecognitionSettings;

public class App {
       public static void main(String[] args) {

        // set license    

        License.setLicense("Aspose.Total.lic");
        boolean resLicense = License.isValid();
        out.println("License is :" + resLicense);

        // Create api instance
        AsposeOCR api = new AsposeOCR();

        String img= "D:/img.png";

        save(api, img);

    }



static void save(AsposeOCR api, String file) throws Exception {
        try {
            RecognitionSettings set =  new RecognitionSettings();
            RecognitionResult result = api.RecognizePage(file, set);
            result.save("D://test.doc", Format.Doc);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}