Results 1 to 2 of 2
  1. #1
    Right Off the Assembly Line
    Join Date
    Dec 2010
    Posts
    12

    Default Java Tutorial 1: Read a pdf file in Java using iText library

    Hi,
    This is a basic tutorial in java, that shows how to read a pdf file. For this we use a library called iText . Using iText library, we can perform various pdf operations that it supports.
    In this section , we are dealing with calculating the no. of pages & extracting the contents of each individual page.The steps are given below :

    Add the iText library, by adding iText.jar to the lib folder of the project.
    Use the following code to extract the content

    Code:
            PdfReader reader = new PdfReader(INPUTFILE);
            int n = reader.getNumberOfPages();
          
      String str=PdfTextExtractor.getTextFromPage(reader, 2); //Extracting the content from a particular page.
                System.out.println(str);
    Note: This program extracts only the text part and not the images.

    Hope this program helps you start with basic pdf editing. Do revert back for queries
    Last edited by thomas6188; 07-01-2011 at 07:29 PM.

  2. #2
    Right Off the Assembly Line
    Join Date
    Oct 2012
    Posts
    1

    Default Re: Java Tutorial 1: Read a pdf file in Java using iText library

    You can also refer to the tutorial series here covering different features of iText:

    PDF Generation in Java: iText Tutorial - QuicklyJava

    Quote Originally Posted by thomas6188 View Post
    Hi,
    This is a basic tutorial in java, that shows how to read a pdf file. For this we use a library called iText . Using iText library, we can perform various pdf operations that it supports.
    In this section , we are dealing with calculating the no. of pages & extracting the contents of each individual page.The steps are given below :

    Add the iText library, by adding iText.jar to the lib folder of the project.
    Use the following code to extract the content

    Code:
            PdfReader reader = new PdfReader(INPUTFILE);
            int n = reader.getNumberOfPages();
          
      String str=PdfTextExtractor.getTextFromPage(reader, 2); //Extracting the content from a particular page.
                System.out.println(str);
    Note: This program extracts only the text part and not the images.

    Hope this program helps you start with basic pdf editing. Do revert back for queries


Similar Threads

  1. Replies: 2
    Last Post: 31-10-2009, 07:00 PM
  2. How to run a simple java program on a Java ready phone?
    By thewisecrab in forum Programming
    Replies: 7
    Last Post: 31-08-2009, 08:53 PM
  3. Replies: 5
    Last Post: 16-05-2009, 02:46 PM
  4. how to convert .class file to .java file???
    By garv84 in forum Programming
    Replies: 4
    Last Post: 11-04-2008, 02:41 PM
  5. plz tell me an online Java Tutorial
    By iinfi in forum QnA (read only)
    Replies: 4
    Last Post: 12-09-2005, 10:09 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Close