You’d pass the FileDocument as a parameter to your Java Action when you call it from a microflow. This will be exposed in the Java Action. WSo if you called the parameter “TheFileDocument” it should be available as this.TheFileDocument in the Java Action. You would use this instead of “filedocument”, for example…
IContext context = getContext();
PDDocument inputDoc = PDDocument.load(Core.getFileDocumentContent(context, this.TheFileDocument.getMendixObject()));
return inputDoc.getNumberOfPages();
Hope this helps