0

我正在尝试从 PHP 脚本运行 PDFToText,但出现以下错误:

Error: Couldn't find trailer dictionaryError: Couldn't open file '/var/www/html/project/pdfdir/estatement.pdf': Permission denied.
Error: May not be a PDF file (continuing anyway)
Error: PDF file is damaged - attempting to reconstruct xref table...
Error: Couldn't find trailer dictionary
Error: Couldn't read xref table
Error: May not be a PDF file (continuing anyway)
Error: PDF file is damaged - attempting to reconstruct xref table...
Error: Couldn't find trailer dictionary
Error: Couldn't read xref table

请注意,pdfdir 文件夹和 Estatement.pdf 文件的权限设置为 777。

我的 PHP 脚本如下所示:

$path = '/var/www/html/project/pdfdir/';
$dir = opendir($path);
$filename = array();

while ($filename = readdir($dir)){
  if (!$filename == '.' || '..'){

    $content = shell_exec('/usr/bin/pdftotext '.$path.$filename.' ');        

    $read = strtok ($filename,".");       

    $testfile = $read.".txt";        

    $file = fopen($testfile,"r");

    if (filesize($testfile) == 0){

      echo "file is empty<br><br>";

    }else{

      $text = fread($file,filesize($testfile));
      echo $text;
      fclose($file);

    }
  }
}

当我独立运行 PDFToText(来自 /usr/bin/pdftotext)时,它可以正常工作。

任何帮助表示赞赏,我不确定下一步该去哪里。

问候

4

0 回答 0