使用php读取pdf文件 [英] Read pdf files using php
问题描述
可能重复:
使用php读取pdf文件
Possible Duplicate:
Read pdf files with php
我有大量的pdf文件.我想用php脚本阅读.我进行了很多搜索,但是每个人都在创建pdf文件.在这里,我不想创建pdf文件,但我想阅读它.有什么方法可以读取php吗?
I have a bulk of pdf documents. I want to read that using php script. I searched a lot, but everyone is about creating pdf files. Here I dont want to create pdf file but I want to read it. Is there any way to read it php?
-阿伦
推荐答案
您可以使用命令行工具(如Pdftotext)轻松读取PDF文件的内容,可以通过exec调用它.
You can easily read the contents of a PDF file using a command-line utility like Pdftotext which you can call through exec.
这是我的意思的示例,实际上是使用系统 >
This is an example of what i mean, actually using system
system("pdftotext your.pdf /tmp/txtfile.txt");
$text = file_get_contents("/tmp/txtfile.txt");
编辑
不知道破折号语法-甚至更好:
didn't know about the dash syntax - this is even better:
$content = shell_exec('pdftotext your.pdf -');
这确实需要在您的服务器上安装pdftotext.在CentOS服务器上,它将是:
This does require pdftotext to be installed on your server though. On a CentOS server this would be:
yum install xpdf
这篇关于使用php读取pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!