From c13a658d5b92802dd806a8ae8a1e134d35452de7 Mon Sep 17 00:00:00 2001 From: Karl Burkhart Date: Mon, 16 Jul 2012 07:41:03 +0000 Subject: [PATCH] =?UTF-8?q?pdf=20konvertieren=20hinzgef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/pdfExport.php | 51 ++++++++++++++++++++++----- content/student/studentoverlay.js.php | 4 +-- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/content/pdfExport.php b/content/pdfExport.php index 03ed419bd..53809e9d3 100644 --- a/content/pdfExport.php +++ b/content/pdfExport.php @@ -124,6 +124,8 @@ if(isset($_GET['typ'])) $params.='&typ='.$_GET['typ']; if(isset($_GET['all'])) $params.='&all='.$_GET['all']; +if(isset($_GET['preoutgoing_id'])) + $params.='&preoutgoing_id='.$_GET['preoutgoing_id']; if(isset($_GET["lvid"])) $params.='&lvid='.$_GET["lvid"]; if(isset($_GET['projekt_kurzbz'])) @@ -133,6 +135,8 @@ if(isset($_GET['version']) && is_numeric($_GET['version'])) else $version =''; +$output = (isset($_GET['output'])?$_GET['output']:'odt'); + if($xsl=='AccountInfo') { $isberechtigt = false; @@ -242,9 +246,21 @@ if(isset($_GET['uid']) && $_GET['uid']!='') $filename=$xsl.$nachname; if (!isset($_REQUEST["archive"])) -{ +{ if(mb_strstr($vorlage->mimetype, 'application/vnd.oasis.opendocument')) { + switch($vorlage->mimetype) + { + case 'application/vnd.oasis.opendocument.text': + $endung = 'odt'; + break; + case 'application/vnd.oasis.opendocument.spreadsheet': + $endung = 'ods'; + break; + default: + $endung = 'pdf'; + } + // Load the XSL source $xsl_doc = new DOMDocument; if(!$xsl_doc->loadXML($xsl_content)) @@ -261,28 +277,47 @@ if (!isset($_REQUEST["archive"])) mkdir($tempfolder); chdir($tempfolder); file_put_contents('content.xml', $buffer); - $zipfile = DOC_ROOT.'system/vorlage_zip/'.$vorlage->vorlage_kurzbz.'.ods'; + + $zipfile = DOC_ROOT.'system/vorlage_zip/'.$vorlage->vorlage_kurzbz.'.'.$endung; $tempname_zip = 'out.zip'; if(copy($zipfile, $tempname_zip)) { exec("zip $tempname_zip content.xml"); clearstatcache(); - $fsize = filesize($tempname_zip); - $handle = fopen($tempname_zip,'r'); - header('Content-type: '.$vorlage->mimetype); - header('Content-Disposition: attachment; filename="'.$vorlage->vorlage_kurzbz.'.ods"'); - header('Content-Length: '.$fsize); + if($output == 'pdf') + { + $tempPdfName = $vorlage->vorlage_kurzbz.'.pdf'; + exec("unoconv --stdout -f pdf $tempname_zip > $tempPdfName"); + + $fsize = filesize($tempPdfName); + $handle = fopen($tempPdfName,'r'); + header('Content-type: application/pdf'); + header('Content-Disposition: attachment; filename="'.$tempPdfName.'"'); + header('Content-Length: '.$fsize); + } + else if($output =='odt') + { + $fsize = filesize($tempname_zip); + $handle = fopen($tempname_zip,'r'); + header('Content-type: '.$vorlage->mimetype); + header('Content-Disposition: attachment; filename="'.$vorlage->vorlage_kurzbz.'.'.$endung.'"'); + header('Content-Length: '.$fsize); + } + while (!feof($handle)) { echo fread($handle, 8192); } fclose($handle); + unlink('content.xml'); unlink($tempname_zip); + if($output=='pdf') + unlink($tempPdfName); rmdir($tempfolder); } } - else + else { if(PDF_CREATE_FUNCTION=='FOP') { diff --git a/content/student/studentoverlay.js.php b/content/student/studentoverlay.js.php index 55b981505..8257d083b 100644 --- a/content/student/studentoverlay.js.php +++ b/content/student/studentoverlay.js.php @@ -4245,8 +4245,8 @@ function StudentCreateDiplSupplement() return false; } - //PDF erzeugen - window.open('content/pdfExport.php?xml=diplomasupplement.xml.php&xsl=DiplSupplement&xsl_stg_kz='+stg_kz+'&uid='+paramList,'DiplomaSupplement', 'height=200,width=350,left=0,top=0,hotkeys=0,resizable=yes,status=no,scrollbars=yes,toolbar=no,location=no,menubar=no,dependent=yes'); + //PDF erzeugen + window.open('content/pdfExport.php?xml=diplomasupplement.xml.php&output=pdf&xsl=DiplSupplement&xsl_stg_kz='+stg_kz+'&uid='+paramList,'DiplomaSupplement', 'height=200,width=350,left=0,top=0,hotkeys=0,resizable=yes,status=no,scrollbars=yes,toolbar=no,location=no,menubar=no,dependent=yes'); } // ****