Export to PDF using LibreOffice 5 command line

This commit is contained in:
Gerhard Stephan 2018-02-15 10:15:27 +01:00
parent f93934905f
commit 51028c845d

View File

@ -574,6 +574,18 @@ IMG;
dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG); dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG);
$this->saveToDisk($name); $this->saveToDisk($name);
// Export to PDF using LibreOffice
if ($conf->global->MAIN_ODT_AS_PDF == 'libreoffice')
{
// Executing convert to PDF using libreoffice 5 (using windows libreoffice must be in path)
$command ='soffice.exe -headless -convert-to pdf -outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name);
exec($command, $output_arr, $retval);
// Split extension from name to allow deleting the source using MAIN_ODT_AS_PDF_DEL_SOURCE
$name=preg_replace('/\.odt/i', '', $name);
}
else
{
$execmethod=(empty($conf->global->MAIN_EXEC_USE_POPEN)?1:2); // 1 or 2 $execmethod=(empty($conf->global->MAIN_EXEC_USE_POPEN)?1:2); // 1 or 2
// Method 1 sometimes hang the server. // Method 1 sometimes hang the server.
@ -652,6 +664,7 @@ IMG;
} }
if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
} }
}
if ($retval == 0) if ($retval == 0)
{ {