将PDF转换为字符串 [英] Converting PDF to string

查看:129
本文介绍了将PDF转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何阅读PDF文件并将内容放入字符串中?使用PHP语言.

How read PDF file and put content into string? Using PHP language.

推荐答案

您可以使用Linux上Xpdf软件包随附的pdftotext之类的东西.然后可以使用popen命令将pdftotext的输出通过管道传递给字符串:

You could use something like pdftotext which comes with the Xpdf package on linux. The popen command can then be used to pipe the output of pdftotext into a string:

$mystring = "";
$fd = popen("/usr/bin/pdftotext blah.pdf","r");
if ($fd) {
    while (($myline = fgets($fd)) !== false) {
        $mystring .= $myline;
    }
}

这篇关于将PDF转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆