You are here

public function MediaPdfThumbnailImagickManager::generateImage in Media PDF Thumbnail 8.2

Same name and namespace in other branches
  1. 8 src/Manager/MediaPdfThumbnailImagickManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImagickManager::generateImage()

Generate image from PDF file.

Parameters

string $source: File source.

string $target: File target.

Return value

string File path.

File

src/Manager/MediaPdfThumbnailImagickManager.php, line 38

Class

MediaPdfThumbnailImagickManager
Class MediaPdfThumbnailImagickManager.

Namespace

Drupal\media_pdf_thumbnail\Manager

Code

public function generateImage($source, $target) {
  try {
    $pdf = new Pdf($source);
    $pdf
      ->saveImage($target);
  } catch (\Exception $e) {
    $this->logger
      ->error($e
      ->getMessage(), [
      'Media Pdf Thumbnail',
    ]);
    return FALSE;
  }
  return TRUE;
}