make libreoffice preview backend work :D

This commit is contained in:
Georg Ehrke 2013-06-05 12:44:31 +02:00
parent 5c1d4fc186
commit 21cc4f6960

View file

@ -26,11 +26,13 @@ if (extension_loaded('imagick')) {
$abspath = $fileview->toTmpFile($path);
chdir(get_temp_dir());
$tmpdir = get_temp_dir();
$exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpdir) . ' ' . escapeshellarg($abspath);
$export = 'export HOME=/tmp';
shell_exec($export . "\n" . $exec);
$exec = $this->cmd . ' --headless -convert-to pdf ' . escapeshellarg($abspath);
exec($exec);
//create imagick object from pdf
try{
$pdf = new \imagick($abspath . '.pdf' . '[0]');
@ -43,7 +45,8 @@ if (extension_loaded('imagick')) {
$image = new \OC_Image($pdf);
unlink($abspath);
unlink($tmppath);
unlink($abspath . '.pdf');
if (!$image->valid()) return false;
return $image;