import com.aspose.ocr.AsposeOCR; import com.aspose.ocr.License; import java.io.File; import java.io.FileWriter; public class ExtractTextFromImageUsingJava { public static void main(String[] args) throws Exception { // main method for extracting text from image License.setLicense("Aspose.OCR.lic"); // Create an instance of AsposeOcr class to apply OCR on an image AsposeOCR TextExtractFromImage = new AsposeOCR(); // Read image using RecognizePage method for text extraction String ExtractedTextFromImage = TextExtractFromImage.RecognizePage("ExampleOCRImageToExtractText.jpg"); // Save extracted text to a text file using FileWriter File output = new File("TextExtractFromImageUsingOCR.txt"); FileWriter writer = new FileWriter(output); writer.write(ExtractedTextFromImage); writer.flush(); writer.close(); } }