Fix odt as PDF generation

This commit is contained in:
fhenry 2013-04-22 12:08:35 +02:00
parent d6514e1cd6
commit e6f9c567d9
2 changed files with 22 additions and 21 deletions

View File

@ -459,7 +459,8 @@ IMG;
$name=str_replace('.odt', '', $name); $name=str_replace('.odt', '', $name);
$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name; $command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name;
//dol_syslog('$execmethod='.$execmethod.' Run command='.$command);
dol_syslog(get_class($this).'::exportAsAttachedPDF $execmethod='.$execmethod.' Run command='.$command,LOG_DEBUG);
if ($execmethod == 1) if ($execmethod == 1)
{ {
exec($command, $output_arr, $retval); exec($command, $output_arr, $retval);
@ -486,16 +487,16 @@ IMG;
if($retval == 0) if($retval == 0)
{ {
//dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
if (headers_sent($filename, $linenum)) { if (headers_sent($filename, $linenum)) {
throw new OdfException("headers already sent ($filename at $linenum)"); throw new OdfException("headers already sent ($filename at $linenum)");
} }
if (!empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { /*if (!empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
header('Content-type: application/pdf'); header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="'.$name.'.pdf"'); header('Content-Disposition: attachment; filename="'.$name.'.pdf"');
readfile("$name.pdf"); readfile("$name.pdf");
} }*/
unlink("$name.odt"); unlink("$name.odt");
} else { } else {
//dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); //dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);

View File

@ -2,21 +2,21 @@
# @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com # @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
if [ -f "$1.odt" ] if [ -f "$1.odt" ]
then then
pgrep -U `id -u` soffice pgrep -U `id -u` soffice
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard soffice --invisible --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard --headless &
sleep 2 sleep 2
fi fi
jodconverter "$1.odt" "$1.pdf" jodconverter "$1.odt" "$1.pdf"
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "Error while converting odt to pdf" echo "Error while converting odt to pdf"
exit 1 exit 1
fi fi
sleep 1 sleep 1
else else
echo "Error: Odt file does not exist" echo "Error: Odt file does not exist"
exit 1 exit 1
fi fi