php - 使用 php 和 pdf 解析器库在大文件夹中搜索 pdf 文件内容
问题描述
我正在使用 pdf 解析器在包含大量 pdf 文件的文件夹中搜索,以便在 pdf 文件内容中进行搜索。该代码仅适用于最多 3 个小尺寸文件:
$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);
}
}
}
}
该代码最多可处理三个文件,否则我会收到消息“无法访问此站点”。我在本地工作,我正在使用 wamp 服务器 - 我正在使用 pdf 解析器库:https ://pdfparser.org 请帮助
解决方案
推荐阅读
- javascript - 使用 JavaScript 创建 Zip 文件的问题
- php - 在 PHP C++ 扩展中标记数据以 curl HTTP 请求
- html - 相关下拉框在编辑时不显示值
- go - 如何修复“go get:警告:在 GOPATH/src 中被 GO111MODULE=auto 禁用的模块”
- neo4j - 获取满足 Neo4J 条件的断开连接的集群数量
- typescript - TypeScript:获取真实类中抽象方法实现的类型
- php - 将 DOCX / Word 生成的 XML 转换为 JSON
- python - 传递变量参数:python
- python-3.x - 如何初始化python看门狗模式匹配事件处理程序
- javascript - 加载项中的 Outlook 对话框无需停用浏览器上的弹出块即可使用