nextcloud/lib/preview/pdf.php

29 lines
759 B
PHP
Raw Normal View History

2013-05-10 01:59:16 +04:00
<?php
/**
* Copyrigjt (c) 2013 Georg Ehrke georg@ownCloud.com
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class OC_Preview_PDF extends OC_Preview_Provider{
public function getMimeType(){
return '/application\/pdf/';
}
public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) {
//create imagick object from pdf
$pdf = new imagick($fileview->getLocalFile($path) . '[0]');
$pdf->setImageFormat('png');
//new image object
$image = new \OC_Image();
$image->loadFromFile($fileview->getLocalFile($path));
//check if image object is valid
if (!$image->valid()) return false;
return $image;
}
}
OC_Preview::registerProvider('OC_Preview_PDF');