Question

PDFBox getNumberOfPages always returns 0

Hi All,

I'm trying to get the total number of pages on the PDF using the PDFBox API(PDDocument). But, on using this method(getNumberOfPages), it always returns 0. Can anyone help me on this issue?. Thanks in advance.

Please find the below code snippet that I'm using.

try{
org.apache.pdfbox.pdmodel.PDDocument doc = new org.apache.pdfbox.pdmodel.PDDocument();
java.io.InputStream instream=new java.io.ByteArrayInputStream( new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(FileContent));
doc.load(instream);
oLog.error("No. of pages in document"+ doc.getNumberOfPages());

}catch(Exception e){

}

Comments

Keep up to date on this post and subscribe to comments