Pages

Tuesday 31 December 2013

GET NUMBER OF PAGE OF PDF FILE USING iTEXT DEMO

For perform this practical you need itext java API. Download it from iText official website.

A simple practical that will count the total number of pages of any pdf file. This may use in e-library like application that i already use.


CountPDFPage.java

import com.itextpdf.text.pdf.PdfReader;

public class CountPDFPage {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        PdfReader reader;
        try {
            reader = new PdfReader("D:\\jreports.pdf");
            int page = reader.getNumberOfPages();
            System.out.println("Number Of pages : "+page); // IT WILL RESULT 339 AS A NUMBER OF TOTAL PDF PAGES.
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
    }

No comments:

Post a Comment