PHPackages                             uiii/processwire-fieldtypepdf - 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. uiii/processwire-fieldtypepdf

ActivePw-module[PDF &amp; Document Generation](/categories/documents)

uiii/processwire-fieldtypepdf
=============================

Fieldtype/Inputfield module for ProcessWire allowing easy generation of thumbnails of the PDF files

2.0.1(1y ago)102132MITPHP

Since Aug 26Pushed 1y ago3 watchersCompare

[ Source](https://github.com/uiii/ProcessWire-FieldtypePDF)[ Packagist](https://packagist.org/packages/uiii/processwire-fieldtypepdf)[ RSS](/packages/uiii-processwire-fieldtypepdf/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (11)Used By (0)

PDF Fieldtype/Inputfield
========================

[](#pdf-fieldtypeinputfield)

[![Packagist](https://camo.githubusercontent.com/0e001e28f61453cf9662814daf35f914f1c984f0096ac862efe3b991ea8be01f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f756969692f70726f63657373776972652d6669656c64747970657064662e737667)](https://packagist.org/packages/uiii/processwire-fieldtypepdf)

Module for [ProcessWire CMS](https://processwire.com) allowing you to easily generate images from the PDF files embedded to the site.

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [How to use](#how-to-use)
    - [In site's administration](#in-sites-administration)
    - [In templates](#in-templates)
4. [API documentation](#api-documentation)
5. [Tests](#tests)
6. [Upgrading from 1.0.1 and lower](#upgrading-from-101-and-lower)
7. [Troubleshooting](#troubleshooting)
8. [Changelog](CHANGELOG.md)

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

[](#requirements)

- Processwire 3+
- ImageMagick PHP extension
- Ghostscript

> For ProcessWire 2.x support use version 1.x, maintained in [pw-2](https://github.com/uiii/ProcessWire-FieldtypePDF/tree/pw-2) branch.

Installation
------------

[](#installation)

[How to install or uninstall modules](http://modules.processwire.com/install-uninstall/).

### Via Composer

[](#via-composer)

In your ProcessWire installation root run:

```
composer require uiii/processwire-fieldtypepdf

```

Login to your ProcessWire admin and go to *Modules* &gt; *Refresh* and install the module.

If you want to read more about ProcessWire and Composer visit

How to use
----------

[](#how-to-use)

### In site's administration

[](#in-sites-administration)

Add a field and set its type to `PDF`. Use the field the same way as the file field (obviously, this accepts only \*.pdf files). After the file is uploaded you will see a small thumbnail of it, just like for image field.

Image generation is highly configurable (image format, extension, background, ...). See the *PDF to image converter* section on field's *Details* tab.

[![Field settings](https://camo.githubusercontent.com/4a0dc172ba55b99c453eb68aed9a258667ecc970530f18a90a7723c9683379c1/687474703a2f2f692e696d67626f782e636f6d2f7850316474333771)](https://camo.githubusercontent.com/4a0dc172ba55b99c453eb68aed9a258667ecc970530f18a90a7723c9683379c1/687474703a2f2f692e696d67626f782e636f6d2f7850316474333771)

### In templates

[](#in-templates)

> There are some backward-compatible API changes against the version 1.0.1 and lower, see [Upgrading from 1.0.1 and lower](#upgrading-from-101-and-lower).

The PDF field extends file field and adds new hookable [`___toImage($page = 0, $options = array())`](http://uiii.github.io/ProcessWire-FieldtypePDF/dev/class-FieldtypePDF.PagePDF.html#____toImage) method to generate the image from PDF.

```
$image = $page->pdfFile->toImage();
$image->size(100, 100);
```

Method accepts two optional parameters. First is the `$page`, which specifies the PDF's page number the image is generated from, default is 0. The exception is thrown if the page is out of range.

The second is `$options` parameter, which is an array of options to override the options set in administration.

```
$options = array(
	'suffix' => array('suffix1', 'suffix2'), // suffixes used in filename
	'forceNew' => false, // if TRUE the image is regenerated if already exists
	'format' => 'JPEG', // image format
	'extension' => 'jpg', // image file extension
	'background' => '#FFFFFF', // background color used when the PDF has transparent background
	'resolution' => '300x300', // resolution used when reading the PDF
	'colorspace' => Imagick::COLORSPACE_RGB, // colorspace used when reading the PDF
	'imagickOptions' => array( // ImageMagick options
		'pdf:use-cropbox=true'
	)
)
```

For each combinations of *page* and *suffixes* there will be one image. The generated images are saved in page's assets and will be **created only once** until *forceNew* options is TRUE. The image is the instance of `Pageimage`, so you can do with it whatever you can do with the image field. When you delete the PDF file the generated images are deleted too.

API documentation
-----------------

[](#api-documentation)

Generate into *doc* directory:

```
apigen generate -d doc

```

Tests
-----

[](#tests)

> **DO NOT** run the tests against the production site. They modify the fields, templates and pages as they need, so can potentially damage your site!

Prepare the PW testing installation and export the `PW_PATH` environment variable containing the path to the root of that installation. Copy the module sources in the `$PW_PATH/site/modules/FieldtypePDF` directory.

Install required packages:

```
composer install

```

Run the tests

```
./vendor/bin/phpunit

```

### Test multiple ProcessWire versions (automatically)

[](#test-multiple-processwire-versions-automatically)

You can also automatically test against multiple ProcessWire versions. It uses [Tense](https://github.com/uiii/tense) tool for it.

1. Install reuquired packages:

    ```
    composer install

    ```
2. Run the tests:

    ```
    vendor/bin/tense run

    ```

> **WARNING**: The tool will ask you for database connection parameters. Configure the `db` connection parameters carefully because it creates and drops a database for each ProcessWire installation.

Upgrading from 1.0.1 and lower
------------------------------

[](#upgrading-from-101-and-lower)

In 1.1.0 some methods of class PagePDF are deprecated. See the list [here](http://uiii.github.io/ProcessWire-FieldtypePDF/dev/deprecated.html). You doesn't have to make any changes but it is recommended to use the new API, for compatibility with later versions.

Instructions for replacing the deprecated methods:

- `$page->pdf->thumbnail($width, $height)` replace with the code

```
$image = $page->pdf->toImage();
$image->size($width, $height);
```

- `isThumbnail($basename)` replace with `isImageOfThis($basename)`

> NOTE: There is certain incompatibility between these two methods. While `isThumbnail` returns TRUE for all the images generated from the PDF and also theirs derivatives (e.g. *pdf.jpg*, *pdf.100x100.jpg*), the `isImageOfThis` return TRUE only for the images generated directly from PDF (e.g. *pdf.jpg*). That doesn't change much, because you can use it in combination with `Pageimage::isVariation`.

- `removeThumbnails` replace with `removeImages`

Troubleshooting
---------------

[](#troubleshooting)

### Thumbnail's colors do not match the colors in PDF

[](#thumbnails-colors-do-not-match-the-colors-in-pdf)

To fix that, you need to made some changes in ImageMagick delegate files. Detailed instructions can be found here:

### GhostScript exceptions occured

[](#ghostscript-exceptions-occured)

If you got some *GhostScript* exceptions when generating image, update *GhostScript* and *ImageMagick* to the latest versions.

If you can't, you can use the **fallback mode**. Turn it on in the module's settings.

> Be aware of that this will produce low quality images and most of the field type options won't be abvailable.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance44

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~388 days

Recently: every ~690 days

Total

9

Last Release

437d ago

Major Versions

1.2.0 → 2.0.02020-12-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/5253d950ce1869bc6397f3507791bcce39834c848701e7ff3321bc8cd95cf05f?d=identicon)[uiii](/maintainers/uiii)

---

Top Contributors

[![uiii](https://avatars.githubusercontent.com/u/179219?v=4)](https://github.com/uiii "uiii (66 commits)")

---

Tags

fieldtypeinputfieldpdfprocesswireprocesswiremodule

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uiii-processwire-fieldtypepdf/health.svg)

```
[![Health](https://phpackages.com/badges/uiii-processwire-fieldtypepdf/health.svg)](https://phpackages.com/packages/uiii-processwire-fieldtypepdf)
```

###  Alternatives

[adrianbj/tracy-debugger

The ultimate debugging and development tool for ProcessWire.

925.2k](/packages/adrianbj-tracy-debugger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
