There's this program, pdftotext, that can convert a pdf file to a text file. To use it directly on the linux console:
That 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:
<?php system('pdftotext file.pdf'); ?>
But when I run this 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.