import com.aspose.words.Document; Document doc = new Document(file.getInputStream()); int num = doc.getPageCount();