title: How to extract the contents of a table in pdf file?
body: <p>I want to extract the contents of a table in pdf like like this :</p>
  
  <p><img src="https://i.stack.imgur.com/upkZz.png" alt="enter image description here"></p>
  
  <p>i wrote this java programme using <a href="http://sourceforge.net/projects/itext/" rel="noreferrer">iText java PDF libray</a> which can read the contents of a PDF file line by line, but I do not know how to get the contents of table</p>
  
  <pre><code>import com.itextpdf.text.pdf.PdfReader;
  import com.itextpdf.text.pdf.parser.PdfTextExtractor;
  
  public class PDFReader {
  
      public static void main(String[] args) {
  
          // TODO, add your application code
          System.out.println("Lecteur PDF");
          System.out.println (ReadPDF("D:/test.pdf"));
      }
          private static String ReadPDF(String pdf_url)
      {
          StringBuilder str=new StringBuilder();
          try
          {
  
           PdfReader reader = new PdfReader(pdf_url);
          int n = reader.getNumberOfPages();
           for(int i=1;i&lt;n;i++)
           {
              String str2=PdfTextExtractor.getTextFromPage(reader, i);
              str.append(str2);
             System.out.println(str);
           }
          }catch(Exception err)
          {
              err.printStackTrace();
          }
          return String.format("%s", str);
      }
  }
  </code></pre>
  
  <p>this is what I get :</p>
  
  <p><img src="https://i.stack.imgur.com/ZSgeR.png" alt="enter image description here"></p>
  
  <p>but that's not what I want, I want to extract the contents of the table line by line and column by column, for example, save each line in an java array</p>
  
  <p>the first array will contain : "N°", "DATE OBSERVATIONS", "TEXTE"</p>
  
  <p>the second array will contain : "029/14", "Le 1er sept 2014 remplace AVURNAV...", "SETE A compter du lundi 7 juillet 2014 débuteront les trav..."</p>
  
  <p>the third array will contain : "037/14", "Le 15 octobre 2014 remplace AVURNAV ...", "SETE Du 15 septembre 2014 au 15 juillet 2015, travaux ...."</p>
  
  <p>and so on</p>
  
  <p>Thanks</p>