title: Parsing PDF tables into csv with php
body: <p>I need to convert a pdf file with tables into CSV, so I used "PDFPARSER" in order to parse the entire text, then with pregmatch_all search the patterns of each table so I can create an array from each table of the pdf.</p>
  
  <p>The structure of the following PDF is:</p>
  
  <p><a href="https://i.stack.imgur.com/DBXFe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DBXFe.png" alt="image"></a></p>
  
  <p>When I parse I get this</p>
  
  <p>ECO-698 Acondicionador Frio-Calor ECO-CHI-522 Chimenea eléctrica con patas</p>
  
  <p>I figured out how to pregmatch_all all the ECO-XXXXX, but I don't know how to pregmatch all the descriptions </p>
  
  <p>This is what is working for ECO-XXXXXX</p>
  
  <pre><code>$parser = new \Smalot\PdfParser\Parser();
  $pdf    = $parser-&gt;parseFile('publication.pdf');
  
  $text = $pdf-&gt;getText();
  echo $text;
  
  $pattern = '/ECO-[.-^*-]{3,}| ECO-[.-^*-]{4,}\s\b[NMB]\b|ECO-[.-^*-]{4,}\sUP| ECO-[.-^*-]{3,}\sUP\s[B-N-M]{1}| ECO-[.-^*-]{3,}\sRX/' ;
  preg_match_all($pattern, $text, $array);
  
  echo "&lt;hr&gt;";
  print_r($array);
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; ECO-698 [1] =&gt; ECO-CHI-522 [2]
  </code></pre>