title: read pdf files using java
body: <p>I want to parse pdf websites.</p>
  
  <p>Can anyone say how to extract all the words (word by word) from a pdf file using java.</p>
  
  <p>The code below extract content from a pdf file and write it in another pdf file. I want that the program write it in a text file.</p>
  
  <pre><code>import java.io.FileOutputStream;
  
  import java.io.IOException;
  
  import com.itextpdf.text.*;
  
  import com.itextpdf.text.pdf.*;
  
  public class pdf {
  
      private static String INPUTFILE = "http://www.britishcouncil.org/learning-infosheets-medicine.pdf" ;
  
      private static String OUTPUTFILE = "c:/new3.pdf";
  
      public static void main(String[] args) throws DocumentException,
              IOException {
  
          Document document = new Document();
  
          PdfWriter writer = PdfWriter.getInstance(document,
                  new FileOutputStream(OUTPUTFILE));
  
          document.open();
  
          PdfReader reader = new PdfReader(INPUTFILE);
  
          int n = reader.getNumberOfPages();
  
          PdfImportedPage page;
  
  
          for (int i = 1; i &lt;= n; i++) {
  
                  page = writer.getImportedPage(reader, i);
  
                  Image instance = Image.getInstance(page);
  
                  document.add(instance);
  
          }
  
          document.close();
  
      }
  
  }
  </code></pre>
  
  <p>Thanks in advance</p>