How to get page count of document files

Posted on 2006-05-05
Last Modified: 2011-04-14

I need to get the page count of doucment files(.doc,.pdf,.ppt,.xml).


FileInputStream fis = new FileInputStream("one.doc);

FileInputStream fis = new FileInputStream("one.pdf);

If one.doc or one.pdf is having 20 pages

int count = fis.getPageCount(); should return value 20

how to achive this

Question by:vallabhaneni99
    LVL 92

    Accepted Solution

    you'll need to habdle each different file type seperately
    use itext for pdf
    try POI for M$ files
    and page count doesn';t really make sense for an xml file
    LVL 30

    Expert Comment


    Open-office can also be used for Word:
    LVL 14

    Expert Comment

    FileInputStream is for raw data extraction. not useful for handling complex file types like documents/images/etc unless you know the file stucture used to store these type of files.
    try the above free libraries to extract/manipulate their contents

    Author Comment

    Hi Objects

    If  possible plz will you give the example code


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now