Comment on page
PDF results thumbnails
Generating thumbnail images for PDF results
Under the Search Sources -> Image settings panel make sure to enable the
Generate thumbnails for PDF files?option.
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.
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.
After logging in via SSH to your system, first make sure every package is up to date:
sudo apt update && sudo apt upgrade -y
Chances are, that Imagick is already installed, run this command to verify:
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)
sudo apt install php8.0-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:
sudo nano /etc/php/8.0/apache2/php.ini
The extension may be enabled already, look for this line:
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:
sudo systemctl restart apache2
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:
sudo nano \etc\ImageMagick-6\policy.xml
Close to the end of the file you should see this line:
<policy domain="coder" rights="none" pattern="PDF" />
Change that line to:
<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.