Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The requirements are the same as for using Kirby's (link: docs/reference/system/
- ImageMagick must be installed on your server.
- Calling PHP's `exec()` method must not be disabled.
- If the ImageMagic convert binary is not correctly linked, you might have to (link: docs/reference/system/options/thumbs#thumbs-driver__additional-options-for-the-imagemagick-driver text: set the path to the `convert` binary) in your config.
- Gostscript is needed

## Setting up the plugin

Expand Down Expand Up @@ -226,20 +227,21 @@ load([
], __DIR__);

Kirby::plugin('cookbook/pdfpreview', [
'hooks' => [
'file.create:after' => function ($file) {
// only create preview for PDF files
if ($file->mime() === 'application/pdf') {
$options = [
'quality' => 100,
'page' => 0,
'density' => 300,
];
$darkroom = new PdfPreview();
$darkroom->process($file->root(), $options);
}
}
],
'hooks' => [
'file.create:after' => function ($file) {
// only create preview for PDF files
if ($file->mime() === 'application/pdf') {
$options = [
'quality' => 100,
'page' => 0,
'density' => 300,
'colorspace' => false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only added options that are different from the defaults, adding the colorspace option here is therefore not necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure?
Without the colorspace attribute, it crashed in my case.

];
$darkroom = new PdfPreview($options);
$darkroom->process($file->root(), $options);
}
}
],
'fileMethods' => []
]);
```
Expand Down