Install APACHE-TIKA on your server.
APACHE-TIKA support more then pdf files.
Install guide:
http://www.acquia.com/blog/use-apache-solr-search-files
and final code is easy:
$string = "";
$fd = popen("java -jar yourpathtotika/tika-app-1.3.jar -t yourpathtopdf/sample.pdf","r");
while (!feof($fd)) {
$buffer = fgets($fd, 4096);
$string .= $buffer;
}
echo $string;