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