mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
Merge branch 'ci' of https://github.com/FH-Complete/FHC-Core into ci
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
* Andreas Moik <moik@technikum-wien.at>.
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/vorlage.class.php');
|
||||
require_once(dirname(__FILE__).'/addon.class.php');
|
||||
@@ -37,8 +38,11 @@ class dokument_export
|
||||
/**
|
||||
* Konstruktor
|
||||
*/
|
||||
public function __construct($vorlage, $oe_kurzbz=0, $version=null)
|
||||
public function __construct($vorlage = null, $oe_kurzbz=0, $version=null)
|
||||
{
|
||||
if(!isset($vorlage))
|
||||
return;
|
||||
|
||||
//Vorlage aus der Datenbank holen
|
||||
$this->vorlage = new vorlage();
|
||||
if(!$this->vorlage->getAktuelleVorlage($oe_kurzbz, $vorlage, $version))
|
||||
@@ -321,7 +325,7 @@ class dokument_export
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = fread($handle, filesize($file));
|
||||
$data = fread($handle, $fsize);
|
||||
fclose($handle);
|
||||
return $data;
|
||||
}
|
||||
@@ -389,5 +393,28 @@ class dokument_export
|
||||
}
|
||||
return $_xml_data->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Konvertiert ein Dokument in ein anderes Format
|
||||
* @param string $inFile Origin File Path
|
||||
* @param string $outFile Output file
|
||||
* @param string $format Format to export To
|
||||
* @return boolean
|
||||
*/
|
||||
public function convert($inFile, $outFile, $format = "pdf")
|
||||
{
|
||||
$command = 'unoconv --format %s --output %s %s';
|
||||
$command = sprintf($command, $format, $outFile, $inFile);
|
||||
|
||||
|
||||
exec($command, $out, $ret);
|
||||
if($ret!=0)
|
||||
{
|
||||
$this->errormsg = 'Dokumentenkonvertierung ist derzeit nicht möglich. Bitte informieren Sie den Administrator';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 fhcomplete.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Andreas Moik <moik@technikum-wien.at>.
|
||||
*/
|
||||
|
||||
class Pdf
|
||||
{
|
||||
public $errormsg = "";
|
||||
|
||||
/**
|
||||
* Fügt beliebig viele PDF Dateien zu einer zusammen
|
||||
* @param array $files Array mit Dateien
|
||||
* @param string $outFile Zieldatei
|
||||
* @return boolean
|
||||
*/
|
||||
public function merge($files, $outFile)
|
||||
{
|
||||
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outFile ";
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
|
||||
// add all pdf files to the command
|
||||
foreach($files as $f)
|
||||
{
|
||||
$cmd .= $f." ";
|
||||
if(!file_exists($f))
|
||||
{
|
||||
$this->errormsg = "File not found: '$f'";
|
||||
return false;
|
||||
}
|
||||
if(finfo_file($finfo, $f) != "application/pdf")
|
||||
{
|
||||
$this->errormsg = "Wrong format: '$f'";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
finfo_close($finfo);
|
||||
|
||||
exec($cmd, $out, $ret);
|
||||
if($ret!=0)
|
||||
{
|
||||
$this->errormsg = 'PDF-zusammenfuegung ist derzeit nicht möglich. Bitte informieren Sie den Administrator';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Konvertiert eine jpeg Datei zu einer PDF
|
||||
* @param string $image jpeg Datei
|
||||
* @param string $outFile Zieldatei
|
||||
* @return boolean
|
||||
*/
|
||||
public function jpegToPdf($image, $outFile)
|
||||
{
|
||||
if(!file_exists($image))
|
||||
{
|
||||
$this->errormsg = "File not found: '$image'";
|
||||
return false;
|
||||
}
|
||||
|
||||
$s = getimagesize($image);
|
||||
|
||||
/*
|
||||
* längere Seite ermitteln
|
||||
* Hochformat wenn die Seiten gleich lang sind.
|
||||
*/
|
||||
if($s[0] > $s[1])
|
||||
{
|
||||
$height = 595;
|
||||
$width = 842;
|
||||
}
|
||||
else
|
||||
{
|
||||
$height = 842;
|
||||
$width = 595;
|
||||
}
|
||||
|
||||
// -r300 = 300 ppi
|
||||
$cmd = 'gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -r100 -o '.$outFile.' viewjpeg.ps -c "('.$image.') << /PageSize [' . $width . ' ' . $height .'] /.HWMargins [18 18 18 13.5] /countspaces { [ exch { dup 32 ne { pop } if } forall ] length } bind def >> setpagedevice viewJPEG"';
|
||||
|
||||
exec($cmd, $out, $ret);
|
||||
if($ret!=0)
|
||||
{
|
||||
$this->errormsg = 'jpegToPdf ist derzeit nicht möglich. Bitte informieren Sie den Administrator';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user