There's this program, pdftotext, that can convert a pdf file to a text file. To use it directly on the linux console:
pdftotext file.pdf
and it will generate a file.txt on the same directory as the pdf file. I was looking for a way to do it from inside a php program, and after some googling i ended with two commands that should work for me: system() and exec(). So i made a php file with this program:
<?php
system('pdftotext file.pdf');
?>
But when i run it code, it doesn't work. No txt file is created. So i tried to create a test file with another command:
<?php
system('touch test.txt');
?>
This worked fine. I've also used exec() and the results were the same. Why doesn't it work?
EDIT: following RoBorg advice, i added the 2>&1 argument to the command, so:
<?php
system('pdftotext file.pdf 2>&1');
?>
it printed a error message:
pdftotext: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory
seems like something is missing on the server.