# PDF results thumbnails

Ajax Search Pro is equipped with code to generate preview thumbnails for PDF results. However this requires a properly configured [Imagick](https://www.php.net/manual/en/book.imagick.php) library.

### Enabling PDF results images

Under the **Search Sources -> Image settings** panel make sure to enable the `Generate thumbnails for PDF files?` option.

![](https://1744076133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M9rmHbZfTKVQ7YzbIZL%2Fuploads%2Fu4sRVo4ZzHxTPSB1hjJ2%2Fimage.png?alt=media\&token=178fdfd6-bd62-4c24-8be7-becf2774c2cc)

## Installing & Enabling the Imagick library

{% hint style="danger" %}
The steps below must be executed via SSH command line on your server. Needless to say, you should be very careful, and always do complete server backups before initializing the commands.
{% endhint %}

### Installation

Installation varies from system to system, we are going to follow a guide for a Ubuntu server with apache and PHP 8, which is the most commonly used system. For the complete guide please check [this article](https://www.linuxcapable.com/how-to-install-php-imagemagick-imagick-on-ubuntu-20-04/).

After logging in via SSH to your system, first make sure every package is up to date:

```bash
sudo apt update && sudo apt upgrade -y
```

Chances are, that Imagick is already installed, run this command to verify:

```bash
php -m | grep imagick
```

If you get "imagick" on the output, then Imagick is installed, you can proceed to the next chapter.

Installing Imagick for PHP (replace the string "8.0" with the major PHP version you are using)

```bash
sudo apt install php8.0-imagick
```

### Enabling Imagick

Open up your php.ini configuration file, usually located at **/etc/php/8.0/apache2/php.ini**

You can use an external editor, or via SSH:

```bash
sudo nano /etc/php/8.0/apache2/php.ini 
```

The extension may be enabled already, look for this line:

```bash
extension=imagick
```

If this line does not exist, then add it after the \[PHP] section. Save the file with **CTRL+O** and exit after saving **CTRL+X**.

After finished, restart apache:

```bash
sudo systemctl restart apache2
```

### Enabling the user policy to open and read PDF files

Imagick by default does not allow opening PDF files, this has to be enabled with a simple change to a single file.

Open up **\etc\ImageMagick-6\policy.xml** in a file editor or via SSH:

```bash
sudo nano \etc\ImageMagick-6\policy.xml
```

Close to the end of the file you should see this line:

```markup
<policy domain="coder" rights="none" pattern="PDF" />
```

![](https://1744076133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M9rmHbZfTKVQ7YzbIZL%2Fuploads%2FwbQXuKyjRoAjExgi5RjF%2Fimage.png?alt=media\&token=3eb45c8a-93f8-41f4-b176-18c25d3369f8)

Change that line to:

```markup
<policy domain="coder" rights="read|write" pattern="PDF" />
```

Save the file with **CTRL+O** and exit after saving **CTRL+X**.

That's it, after this configuration the PDF files should have a preview image generated in the live search results list.
