We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

doc.getPageCount() returns incorrect page number

I am trying to use doc.getPageCount() to return the total number of pages in a document but it returns incorrect page count when i use the code below

public int getDocumentPageCount(InputStream in) throws Exception
{
com.aspose.words.Document doc = new com.aspose.words.Document(in);
return (doc !=null ? doc.getPageCount() : 0);
}

but if i change the code to below, the correct page count is returned

public int getDocumentPageCount(InputStream in) throws Exception
{
com.aspose.words.Document doc = new com.aspose.words.Document("C:\temp\file.doc");
return (doc !=null ? doc.getPageCount() : 0);
}

Can you help, i need the first option to work

Hi Okechukwu,


Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document you’re getting this problem with.
  • Please create a standalone (runnable) Java application that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information.

Best regards,