Import community commons from the appstore. Create a java action with a parameter filedocument and return integer.
// BEGIN USER CODE
IContext context = getContext();
PDDocument inputDoc = PDDocument.load(Core.getFileDocumentContent(context, filedocument.getMendixObject()));
return inputDoc.getNumberOfPages();
// END USER CODE
Hey Kofi,
I just published a module which contains a number of Java actions to extract the contents and metadata of PDF files, one of which is to get the number of pages in your PDF document.
You can find the module here: https://appstore.home.mendix.com/link/app/109922/
Hope it helps in the future.