2

I installed the required library and its working in terminal but not in my php file. My code is :

$mypdf = shell_exec('/usr/local/bin/pdftotext test.pdf test.txt');
echo $mypdf;

If I execute this command /usr/local/bin/pdftotext test.pdf test.txt in terminal it works fine.

I also write my code this type :

shell_exec('/usr/local/bin/pdftotext test.pdf test.txt');
$mypdf = file_get_contents("test.txt");
echo $mypdf;

In Error Log the message is :

/usr/local/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)
rekire
  • 47,260
  • 30
  • 167
  • 264

3 Answers3

1

My guess would be that you're expecting $mypdf to contain the PDF document instead of the return value of the executed command. If you're trying to print out 'test.txt', then you'll need to load it up and print it.

Infiltrator
  • 1,611
  • 1
  • 16
  • 25
  • 1
    Or do something like `$mypdf = shell_exec('/usr/local/bin/pdftotext.exe test.pdf /dev/stdout');` – JohnB Sep 01 '12 at 08:55
  • my command should create `test.txt` file in current directory but it is not creating. I check this issue that is related to mine "http://www.webdeveloper.com/forum/archive/index.php/t-254155.html" but didn't help me –  Sep 01 '12 at 09:04
  • use my code like this also `shell_exec('/usr/local/bin/pdftotext.exe test.pdf test.txt'); $mypdf = file_get_contents("test.txt"); echo $mypdf;` –  Sep 01 '12 at 09:07
  • @SumitMadan Are you sure that the working directory of the php being executed is the same as when you ran it manually? It may not be able to find 'test.pdf' in the working directory. – Infiltrator Sep 01 '12 at 09:13
  • i ran this command `shell_exec('mkdir test');` and it is creating the directory in current directory. –  Sep 01 '12 at 09:17
1

Issue was: /usr/local/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version 'GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)

And the solution was to rename /opt/lampp/lib/libgcc_s.so.1 to libgcc_s.so.1.bak and solves my problem. But confusion is that what was the issue in it :P

0

I think you have some trouble with a dependency. Check your error.log. Find out which file is missing and add it to the path environment variable of your php installation.

rekire
  • 47,260
  • 30
  • 167
  • 264
  • only '/usr/local/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)' error in the error_log –  Sep 01 '12 at 09:31