innoweb/silverstripe-pdf-image-converter

Converts the first page of a PDF file to an image

1.0.2 2024-11-12 04:13 UTC

This package is auto-updated.

Last update: 2024-12-12 22:05:51 UTC


README

Version License

Overview

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.

Requirements

  • Silverstripe Assets 2.3 (Silverstripe 5.3)
  • ext-imagick

Installation

Install the module using composer:

composer require innoweb/silverstripe-pdf-image-converter

Then run dev/build.

Usage

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>

License

BSD 3-Clause License, see License