PHPackages                             bymayo/pdf-transform - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. bymayo/pdf-transform

ActiveCraft-plugin[PDF &amp; Document Generation](/categories/documents)

bymayo/pdf-transform
====================

Transform a PDF page to an image (JPEG, PNG)

5.1.0(4mo ago)1211.8k10[1 PRs](https://github.com/bymayo/craft-pdf-transform/pulls)MITPHPCI failing

Since Oct 26Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/bymayo/craft-pdf-transform)[ Packagist](https://packagist.org/packages/bymayo/pdf-transform)[ RSS](/packages/bymayo-pdf-transform/feed)WikiDiscussions craft-5 Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (26)Used By (0)

[![](https://github.com/bymayo/craft-pdf-transform/raw/craft-5/resources/icon.png)](https://github.com/bymayo/craft-pdf-transform/blob/craft-5/resources/icon.png)

PDF Transform for Craft CMS 5
=============================

[](#pdf-transform-for-craft-cms-5)

PDF Transform is a Craft CMS plugin that transforms a PDF stored in Assets, to an image. This can then be output via Twig in to a template.

A use case for this is to show the preview of a PDF before a user downloads that particular file.

Features
--------

[](#features)

- Transform PDF's to images via Twig (The file needs to be an existing Asset element)
- PDF's are transformed to an image when PDF's are uploaded via Assets or Asset fields.
- Transformed PDF images are indexed and available in Assets like all other asset elements.
- Works with local asset volumes, Amazon S3 and Servd.
- Control where generated images are placed (volume root, subfolder, or mirror source path).
- Restrict auto-transform to specific source volumes.

Install
-------

[](#install)

- Install with Composer via `composer require bymayo/pdf-transform` from your project directory
- Enable / Install the plugin in the Craft Control Panel under `Settings > Plugins`
- Customise the plugin settings, **especially** the `Image Volume` option.

You can also install the plugin via the Plugin Store in the Craft Admin CP by searching for `PDF Transform`.

Requirements
------------

[](#requirements)

- Craft CMS 5.x
- Imagick / Ghostscript
- MySQL (No PostgreSQL support)

Configuration
-------------

[](#configuration)

All settings can be configured from the plugin settings page in the Control Panel, or via a `config/pdf-transform.php` config file.

  **Setting** **Default** **Description**   Page Number `1` Set which page in the PDF should be converted to an image.   Image Volume `null` Choose which volume converted images should be stored in.   Output Destination `root` Where within the output volume to place generated images. Options: `root` (volume root), `subfolder` (static subfolder), `mirror` (mirror the source PDF's folder path).   Subfolder Name `''` When Output Destination is set to `subfolder`, the name of the subfolder to place images in (e.g. `thumbnails`).   Image Resolution `72` Set the resolution of the converted image.   Image Quality `100` Set the image quality of the converted image.   Clean Filenames `false` Remove `.pdf` from output filenames (e.g. `document-123.jpg` instead of `document.pdf-123.jpg`).   Colour Space `srgb` Colour space for the converted image. Options: `srgb`, `rgb`, `cmyk`, `gray`, `none`. sRGB fixes inverted colours on CMYK PDFs.   Image Format `jpg` Set the file format of the converted image. Options: `jpg`, `png`.   Source Volumes `['*']` Which volumes trigger auto-transform when a PDF is uploaded. Set to `['*']` for all volumes, or an array of volume IDs. This does not affect the `craft.pdfTransform.render()` Twig method. ### Config File

[](#config-file)

You can override plugin settings by creating a `config/pdf-transform.php` file in your Craft project:

```
