That’s how I create thumbs for my pdf files:
'file.create:after' => function (Kirby\Cms\File $file) {
if ($file->template() == "flyer") {
$im = new Imagick();
$im->setResolution(72,72);
$im->readimage($file->root() . '[0]');
$im->setImageFormat('jpeg');
$im->writeImage(dirname($file->root()) . '/' . $file->name() . '.jpg'); // temp
$im->clear();
$im->destroy();
Kirby\Cms\File::create([
'source' => dirname($file->root()) . '/' . $file->name() . '.jpg',
'parent' => $file->page(),
'filename' => $file->name() . '-preview.jpg',
'template' => 'preview'
]);
Kirby\Toolkit\F::remove(dirname($file->root()) . '/' . $file->name() . '.jpg'); // delete temp
}
},
And I realize that I am not checking if it actually is a pdf. So I might should do that before creating the thumb…