使用 PHP 搜索 PDF 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1882318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:09:49  来源:igfitidea点击:

Search through PDF files with PHP

phpsearchpdf

提问by Ben Fransen

I'm trying to find a way to search inside PDF files. I came accross the PHP PDF class but I can't seem to find any function for reading/searching a filestream.

我正在尝试找到一种在 PDF 文件中进行搜索的方法。我遇到了 PHP PDF 类,但似乎找不到任何用于读取/搜索文件流的函数。

So, as naive as I am, i tried to simple get a stream using file_get_contents(), obviously it's an encrypted-like output ;)

因此,尽管我很天真,但我尝试使用 file_get_contents() 来简单地获取流,显然它是一个类似加密的输出;)

So my question, is there any way to search through PDF files? I'm looking for script-only / free / open source solutions and not buying some expensive commercial libraray.

所以我的问题是,有没有办法搜索PDF文件?我正在寻找纯脚本/免费/开源解决方案,而不是购买一些昂贵的商业图书馆。

采纳答案by Daniel May

XPDF?

XPDF?

There is a blog post herethat may be of help.

有一个博客张贴在这里可能会有所帮助。

There seems to be some code herethat could help - a simple class that reads a PDF into plaintext. Unsure if it supports decryption.

似乎有一些代码在这里,可以帮助-一个简单的类读取PDF成明文。不确定它是否支持解密。

There are also a number of resources in PHP documentation that may help you. Click.

PHP 文档中还有许多资源可以帮助您。点击。

FPDFand FPDImay also help. Probably your best bet after some research.**

FPDFFPDI也可能有所帮助。经过一些研究,可能是您最好的选择。**

回答by akamike

A PHP search engine called Sphiderhas the option of adding PDF search via XPDF. You can then customise the result templates to fit in with the rest of your site (if applicable).

一个名为Spider 的PHP 搜索引擎可以选择通过 XPDF 添加 PDF 搜索。然后,您可以自定义结果模板以适应网站的其余部分(如果适用)。