I am trying to convert a pdf file into text file. When I run the command through terminal its working fine but when try to execute it through PHP it’s not working.
I am stuck in this situation from last four hour spend lots of time in google but no solution available. Can any body resolve this issue?
File owner – nobody
shell_exec('/usr/bin/pdftotext /opt/lampp/htdocs/foldername/filename.pdf');
Can anyone provide any helpful solution?
I also tried to change usr folder ownership from root to nobody and provide 777 permission on folder and its context.
Your command to run pdftotext is not correct.
There should be a second argument telling pdftotext to write to a specific file or just use a dash “-” to write to stdout, unless you actually want the program to create a text-file with the filename as the pdf (this would require write permissions in the /opt/lampp/…/ folder)
This is at least true for
pdftotext version 0.12.4So, the solution to your question would simply be add a dash after the filename, like so:
Provided that the binary exists and PHP is allowed to use shell_exec and you have permissions and that the pdf-file exists and you have permissions.