title: how to extract texts from PDFs using xpdf?
body: <p>I have many PDFs in a folder. I want to extract the text from these PDFs using xpdf. For example :</p>
  
  <ul>
  <li>example1.pdf extract to example1.txt</li>
  <li>example2.pdf extract to example2.txt</li>
  <li>etc..</li>
  </ul>
  
  <p>here is my code :</p>
  
  <pre><code>&lt;?php
  
  $path = 'C:/AppServ/www/pdfs/';
  $dir = opendir($path);
  $f = readdir($dir);
  
  while ($f = readdir($dir)) {
      if (eregi("\.pdf",$f)){
          $content = shell_exec('C:/AppServ/www/pdfs/pdftotext '.$f.' ');
          $read = strtok ($f,".");
          $testfile = "$read.txt";
          $file = fopen($testfile,"r");
          if (filesize($testfile)==0){} 
          else{
             $text = fread($file,filesize($testfile));
          fclose($file);
          echo "&lt;/br&gt;"; echo "&lt;/br&gt;";
          }
      }
  }
  </code></pre>
  
  <p>I get blank result. What's wrong with my code?</p>