This module converts the first page of a PDF file to an image.
It uses the high level conversion API introduced in Silverstripe 5.3, see the image documentation.
- Silverstripe Assets 2.3 (Silverstripe 5.3)
- ext-imagick
Install the module using composer:
composer require innoweb/silverstripe-pdf-image-converter
Then run dev/build.
To display a thumbnail of a PDF file in a template you can convertthe PDF to an image in the template:
<img src="$PDFDocument.Convert('jpg').Pad(100,150).URL" height="150" width="100" alt="">
You can use the Quality
method to set a specific image quality for different formats:
<picture>
<source type="image/webp" srcset="$PDFDocument.Convert('webp').Quality(80).Pad(100,150).URL">
<img src="$PDFDocument.Convert('jpg').Pad(100,150).URL" height="150" width="100" alt="">
</picture>
BSD 3-Clause License, see License