如何在Zpanel的VPS上使用XPDF?

时间:2014-10-04 23:04:32

标签: php linux vps xpdf

我正在尝试制作一个网页,使用xpdf将pdf转换为文本文件 下面是使用xampp在Windows上执行此操作的PHP代码。

<?php
$filename = array();
$filename ="/Applications/XAMPP/xamppfiles/htdocs/abc/test.pdf";//Path of the file

//while ($filename = readdir($dir)) {
if (eregi("\.pdf",$filename)){

$content  = shell_exec('/usr/local/bin/pdftotext -raw'.' '.$filename.' -');//$content stores the content of the pdf as string



$read =basename($filename,".pdf");//extracting file name 
$testfile = "$read.txt";//changing extension of filename
$file     = fopen("/Applications/XAMPP/xamppfiles/htdocs/".$testfile,"w");// creates new file of the same name in at the given location
fwrite($file, $content);//writes content to file
if (filesize($testfile)==0){} //checks if file null
else{
$text = fread($file,filesize($testfile));
fclose($file);
echo "</br>"; echo "</br>";
}
}?>

现在我想在Linux VPS上运行它 我有一个具有SSH访问权限的Cent OS VPS。我安装了zpanel,xpdf(使用yum install xpdf) 现在我想,当我在浏览器中打开这个URL“www.website.com/convert.php”时,public_html文件夹中的test.pdf文件应该转换为同一文件夹中的test.txt。

那么,我应该在convert.php中编写什么代码?

0 个答案:

没有答案