Get OCR Result as file

Get OCR Result as file

Aspose.OCR for Java provides the class RecognitionResult that contains elements with recognition information and result. To get the result in Document format, you may use the save method of the RecognitionResult class.

The following code snippet demonstrates the use of the save method to save the recognition result in file that is generated by the RecognizePageFromUri method.

Sample Code

...

	// For complete examples and data files, please go to https://github.com/aspose-ocr/Aspose.OCR-for-Java

	// Get image for recognize
	String uri = "https://qph.fs.quoracdn.net/main-qimg-0ff82d0dc3543dcd3b06028f5476c2e4";

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

	try {
	RecognitionSettings set = new RecognitionSettings();
		RecognitionResult result = api.RecognizePageFromUri(uri, set);
		System.out.println("File: " + uri);
		System.out.println("Result line: " + result.recognitionText);
	} catch (IOException e) {
		e.printStackTrace();
	}

Select file format for result

Aspose.OCR for Java provides the option to specify the Document format for result saving. For this, the API provides the Format enumeration. The Format enum has the following members.

Member Description
Text Saves the document in the plain text format.
Docx Saves the document as an Office Open XML WordprocessingML Document (macro-free).
Pdf Saves the document as an PDF (Adobe Portable Document) format.
Xlsx Saves the result as an Excel ( 2007 and later) workbook Document.