0

I want to read pdf or doc document's text content in wordpress plugin. I downloaded xpdf and I used it to get content. But in wordpress plugin or theme I can't get the content.

$filename = "try.pdf";
echo $filename;
$content = shell_exec('xpdf\pdftotext ' . $filename . ' -');
echo $content;

I used this code in plugin, but $content variable is null. How can i solve this problem?

Cœur
  • 37,241
  • 25
  • 195
  • 267
eagle
  • 301
  • 1
  • 2
  • 5

1 Answers1

0

You are trying to execute command via shell and return the complete output as a string via shell_exec function, but this function is disabled when PHP is running in safe mode. If you do not get the output from the executed command, then NULL is returned if an error occurred. Most probably you have also (if you are running PHP is safe mode) a permissions problem on your hosting server. Try to get the file contents by avoiding shell_exec function and using regular file manipulation functions like fopen, fread, file_get_contents.

Bud Damyanov
  • 30,171
  • 6
  • 44
  • 52