0

I'm using pdf parser to search in folder contains a lot of pdf files to search within pdf files content. the code is working fine for only maximum 3 files with small sizes:

$keyword = "Calibri";  //the keyword is dynamic

$dir = new DirectoryIterator('C:\wamp\www\pdfdemos\cv');
$parser = new \Smalot\PdfParser\Parser();
foreach ($dir as $file) {
    if($file->isFile() && $file->getExtension() =='pdf'){
        if ($file->getFilename() =="." || $file->getFilename() =="..") {
            continue;
        }else{
            echo "File name: ".$file->getFilename()."<br />";
            $pdf= $parser->parseFile('C:\wamp\www\pdfdemos/cv/'.$file->getFilename());
            $pages  = $pdf->getPages();
            $text = $pdf->getText();

            if(stripos(strtolower($text), $keyword)) {
                         echo "Keyword Matches";
                         echo "<br/><hr />";
                      }else{
                           echo "Keyword Not Matches";
                           unset($text);
                     }
        }
    }                                               

}

The code is working with maximum three files, otherwise i get the message "This site can’t be reached". i'm working locally and i'm using wamp server - i am using pdf parser library: https://pdfparser.org Please Help

hany
  • 49
  • 1
  • 10

0 Answers0