pdf, determine number of page

0
Hello,  how can I determine how many pages a pdf document have? Thanks
asked
1 answers
1

I believe you’d need to drop into Java do this.

The PDFBox library includes a getNumberOfPages() method which can be used to get this. If you have Community Commons installed this library is installed as part of the module, if not you’d have to download it separately.

Something like this should work (untested).
 

PDDocument pdfDoc = PDDocument.load(Core.getFileDocumentContent(this.getContext(), yourDocument.getMendixObject()));
return pdfDoc.getNumberOfPages();


I will try to refine, test, and submit a version of this for inclusion in Community Commons later.

answered