Création de vignette de preview pour un document pdf

Par oumar_sama, il y a 9 ans


Bonjour,

j'utilise vichuploaderbundle pour uploader des pdfs que j'aimerais récupérer dans le controlleur pour générer des vignettes de preview.
je récupère l'objet Response mais je ne sais pas comment le traiter pour en extraire le document afin de générer la vignette

voici la classe d'"extraction" de la couverture

<?php namespace Siraat\AdDinBundle\PdfLoader; /** * ImageExtractor */ class ImageExtractor { const FORMAT_JPG = 'jpg'; const FORMAT_PNG = 'png'; /** * @param string $source source filepath * @param string $destination destination filepath * @param string $format destination format * * @return bool */ public static function extract($source, $destination, $format = self::FORMAT_PNG) { if (!extension_loaded('Imagick')) { return false; } $imagick = new \Imagick($source.'[0]'); $imagick->setFormat($format); return $imagick->writeImage($destination); } }

voila mon controleur

public function indexAction(Request $request) { $em = $this->getDoctrine()->getManager(); $document = $em->getRepository('SiraatAdDinBundle:Document')->findById($id); $downloadHandler = $this->get('vich_uploader.download_handler'); $response = $downloadHandler->downloadObject($document, $fileField = 'documentFile'); /*... j'ignore comment passer $response a ma classe ImageExtractor */ return $this->render('SiraatAdDinBundle:Main:index.html.twig', array('document' => $document)); }

Aucune réponse