Aspose OCR integration

0
Hello Team, I am trying to implement OCR functionality in mendix  and My use case is when I upload a image and click the button then it has to extract all the text present on the image. So, I am going with Aspose Api where they will provide java libraries and with that, we have to use java to write code to extract text. But this is my first time to work with java actions and on integrating part. So, need guidance to proceed further. Any Suggestions would be appreciated.   Thanks In advance,
asked
1 answers
0

You will need to pass the filedocument as argument to the java action.

Then extract the content from the file (look at the Core class for this, see https://apidocs.rnd.mendix.com/8/runtime/com/mendix/core/Core.html#getFileDocumentContent(com.mendix.systemwideinterfaces.core.IContext,com.mendix.systemwideinterfaces.core.IMendixObject)) and follow something like the code below where you'll need a inputstream for the extracted content to write this to a new filedocument.

Hope this gives you some idea on how to proceed.

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();

answered