MediaPdfThumbnailImagickManager.php in Media PDF Thumbnail 8.3
Same filename and directory in other branches
Namespace
Drupal\media_pdf_thumbnail\ManagerFile
src/Manager/MediaPdfThumbnailImagickManager.phpView source
<?php
namespace Drupal\media_pdf_thumbnail\Manager;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Spatie\PdfToImage\Pdf;
/**
* Class MediaPdfThumbnailImagickManager.
*
* @package Drupal\media_pdf_thumbnail\Manager
*/
class MediaPdfThumbnailImagickManager {
/**
* @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
*/
protected $logger;
/**
* MediaPdfThumbnailImagickManager constructor.
*
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannel
*/
public function __construct(LoggerChannelFactoryInterface $loggerChannel) {
$this->logger = $loggerChannel
->get('Media PDF Thumbnail');
}
/**
* Generate image from PDF file.
*
* @param string $source
* File source.
* @param string $target
* File target.
*
* @return string
* File path.
*
*/
public function generateImageFromPDF($source, $target) {
try {
$pdf = new Pdf($source);
$pdf
->saveImage($target);
} catch (\Exception $e) {
$this->logger
->error($e
->getMessage());
return FALSE;
}
return TRUE;
}
}
Classes
Name | Description |
---|---|
MediaPdfThumbnailImagickManager | Class MediaPdfThumbnailImagickManager. |