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');
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');
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;
}
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
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.