kaleu62 / pi-reader
简单的PDF和图像解析器
v0.9
2023-01-09 08:44 UTC
Requires
- php: >=7.1
- guzzlehttp/guzzle: >=6.3
- spatie/pdf-to-text: ^1.1
Requires (Dev)
- phpunit/phpunit: >=7.0
Suggests
- spatie/pdf-to-text: Needed to install the lib pdftotext, in Debian: 'apt-get install -y xpdf', or in CentOS: 'yum install poppler-utils'
README
这是一个使用 spatie/pdf-to-text 和来自 https://ocr.space/ 的API的PDF和图像阅读器。
如何使用?
$pireader = new PIReader(
[
'apiKey' => 'xxxxxxxxx', // ocr.space API Key
'production' => false
]
);
由于ocr.space请求的限制,'apiKey'参数是必需的,但只有当'production'参数设置为true时,才会使用它的apiKey。
应用程序目前包含一些非常基本的功能
- 返回OCR解析的文本
- 验证文档中是否存在文本
- 计算文档中文本出现的次数
- 通过正则表达式在文本中搜索
getArchive($filePath)
此函数返回一个包含文件(PDF或图像)路径中解析内容的文本数组的数组
$pireader->getArchive("http://my_fake_pdf_path/file.pdf");
existsInFile($filePath, $string)
此函数返回一个布尔值,指示文本是否存在于提供的路径的文件中,如果文件正确打开,则返回布尔值,否则返回null
$pireader->existsInFile("http://my_fake_pdf_path/file.pdf", "John Doe");
countOccurrences($filePath, $string)
$pireader->countOccurrences("http://my_fake_pdf_path/file.pdf", "John Doe");
regexFind($filePath, $regex)
$pireader->regexFind("http://my_fake_pdf_path/file.pdf", "[\d{5}\.\d{5} \d{5}\.\d{6} \d{5}\.\d{6} \d{1} \d{14}]");