Better error message in convert odt to pdf
This commit is contained in:
parent
9fc523bca7
commit
3c90461502
@ -584,7 +584,7 @@ IMG;
|
||||
// using windows libreoffice that must be in path
|
||||
// using linux/mac libreoffice that must be in path
|
||||
// Note PHP Config "fastcgi.impersonate=0" must set to 0 - Default is 1
|
||||
$command ='soffice -headless -convert-to pdf -outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name);
|
||||
$command ='soffice --headless --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name);
|
||||
}
|
||||
elseif (preg_match('/unoconv/', $conf->global->MAIN_ODT_AS_PDF))
|
||||
{
|
||||
@ -635,6 +635,7 @@ IMG;
|
||||
//$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name.' '.$dirname;
|
||||
|
||||
dol_syslog(get_class($this).'::exportAsAttachedPDF $execmethod='.$execmethod.' Run command='.$command,LOG_DEBUG);
|
||||
$retval=0; $output_arr=array();
|
||||
if ($execmethod == 1)
|
||||
{
|
||||
exec($command, $output_arr, $retval);
|
||||
@ -665,6 +666,7 @@ IMG;
|
||||
if ($retval == 0)
|
||||
{
|
||||
dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
||||
$filename=''; $linenum=0;
|
||||
if (headers_sent($filename, $linenum)) {
|
||||
throw new OdfException("headers already sent ($filename at $linenum)");
|
||||
}
|
||||
@ -681,16 +683,17 @@ IMG;
|
||||
}
|
||||
} else {
|
||||
dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
||||
dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr,true), LOG_DEBUG);
|
||||
dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr, true), LOG_DEBUG);
|
||||
|
||||
if ($retval==126) {
|
||||
throw new OdfException('Permission execute convert script : ' . $command);
|
||||
}
|
||||
else {
|
||||
$errorstring='';
|
||||
foreach($output_arr as $line) {
|
||||
$errors.= $line."<br>";
|
||||
$errorstring.= $line."<br>";
|
||||
}
|
||||
throw new OdfException('ODT to PDF convert fail : ' . $errors);
|
||||
throw new OdfException('ODT to PDF convert fail (option MAIN_ODT_AS_PDF is '.$conf->global->MAIN_ODT_AS_PDF.', command was '.$command.', retval='.$retval.') : ' . $errorstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user