number of page of document in Java

I have the base64 and the byte[] of a pdf document, and I need to obtain from this number of page of the document how I could do it.

PdfReader reader = Here my question 
int ret = reader.getNumberOfPages();


Your question is not quite clear. What do you mean that you have the base64 encoded byte[]? Normally you either have a base64 encoded string or an byte[].

import java.util.Base64;


 //do this if it is base64 encoded otherwise directly use the byte[]
 byte[] decodedPdf = Base64.getDecoder().decode(yourBase64encodedPdf);

 PdfReader reader = new PdfReader(decodedPdf);
 int numOfPages = reader.getNumberOfPages();

Source: stackoverflow