Reputation: 872
I want to convert a pdf into html in PHP
by running this command
pdftohtml -i -c test/invoice.pdf test/invoice.html
but it's not working using this PHP
code
$data=exec('pdftohtml -i -c test/invoice.pdf test/invoice.html');
Upvotes: 0
Views: 542
Reputation: 872
I have solved above question by giving permission to folder having issue due to folder is not writable its difficult for me to find because it's not showing any error on my Ubuntu machine, even its error mode and debugging is on.
Upvotes: 1
Reputation: 4696
You may need to provide the full path for the pdftohtml
. For example if you are on linux you can do
whereis pdftohtml
You may then see /usr/bin
for example, therefore changing the line to read
/usr/bin/pdftohtml -i -c ./test/invoice.pdf ./test/invoice.html
This may resolve your issue. If you are on Linux you can also check the logs, for example:
tail -f /var/log/httpd/error.log
You may be able to track the error this way. Finally another option is to run the php file from the browser and check for output, then try from command line and again check for output. If you can nail down if under both instances there is an issue we would likely be closer to the solution.
Upvotes: 0
Reputation: 1
what kind of error you get after execute the command? try maybe other feature etc. shell_exec http://php.net/manual/ru/function.shell-exec.php
Upvotes: 0
Reputation: 3415
You may need to run the command as root.
I had this issue once and ended up writing a script that SSH'd into itself.
$this->root_execute('pdftohtml -i -c test/invoice.pdf test/invoice.html');
-
public function root_execute($command = '')
{
set_include_path('/path/to/dir/ssh/');
require_once('Net/SSH2.php');
$ssh = new Net_SSH2(SSH_HOST);
if (!$ssh->login(SSH_USER, SSH_PASS)) {
exit('failed');
}
$res = $ssh->exec($command);
$ssh = null;
restore_include_path();
return $res;
}
Upvotes: 0