Can't see PDF thumbnails in new grid view (but works in the demo instance)

I’m trying to get my nextcloud instance to show thumnail images of pdf files when in the new grid view in Nextcloud 15.

In the demo ( when viewing in grid view this works just as I would like it to. However, a new fresh instance of nextcloud (installed from the nextcloud docker) doesn’t have this. I don’t see any difference in the settings between my instance and the demo instance.

What do I need to do to make pdf thumbnails show up like the demo instance has?

Is there a way to look at the config.php file for the instance so I can see how it manages to make PDF thumbnails show up?

It must not be difficult to make PDF thumbnails show up since the demo does it.

Anyone know how? Thanks for helping!

Maybe try installing ghostscript.

Can you give any more details? I searched google for “nextcloud ghostscript” but most of the results had to do with people’s posts about problems with previewgenerator.
How do I install ghostscript? Is there a way to tell if it is already installed? If ghostscript is for creating a preview of PDF files (which based on its website it seems to be) then I must already have it installed because I can see PDFs in nextcloud no problem when I click on the filename (opens in a full-sized preview of the entire PDF). Doesn’t that mean I must already have ghostscript?

The problem I’m having is with there being no thumbnail preview of a file in the grid view. I can see PDFs when they are clicked on to open just fine.

I.e., Here is my problematic install:

And here is the (working) version:

If you still think the problem is ghostscript, can you give me any further pointers?

If anyoneone knows how I can view the config.php from the demo instance, can you let me know? Then I could just see what settings are used there. Thanks!

Anyone? There must be an easy way to make my instance of Nextcloud work the same as the demo instance.

I think for previewing, Nextcloud uses imagemagick. And for previewing pdf files, imagemagick needs ghostscript. So you would need to install the ghostscript package on your system, not in NC.

Right. But there’s no problem for me in previewing pdf files. I click on the file, and the preview shows up, full size.

So unless I’m mistaken, this isn’t a ghostscript or imagemagick problem. Previews are working for me.

The problem I have is that in the grid view, I see generic icons, instead of the icon-sized previews.

I want this: (seen in the nextcloud demo–notice the two files on the right, labeled Nextclo… and User Da…–these are both previews of pdfs instead of generic adobe acrobat pdf icons)

But I have this:

What am I missing?

Well, shame on me for just assuming that it couldn’t be a imagemagick/ghostscript problem.

I did docker exec -it nextcloud /bin/bash to get into my nextcloud docker
Then I did apt update and then apt install imagemagick and let it install
And then went back to nextcloud in the browser, and just like that, pdf icon previews are working!

You were right!

Thanks for your help

1 Like

I have ghsotscript and imagemagick installed, as well as the Preview App, but no preview for PDF files.

Error log is telling me:

ImagickException: not authorized/tmp/oc_tmp_ga2e3G-.pdf’ @ error/constitute.c/ReadImage/412`

Fresh installation of Ubuntu 18.04 and Nextcloud 15.05
What is wrong there?

More details of error message

@fivestones thank you, thank you, thank you!

I’ve been looking for this for months! So far I had PDF thumbnails enabled in some config file but apparently that was not enough. Installing imagemagick did the trick and the PDF thumbnails appeared instantly!

I really can’t understand why they don’t document on how to get such a primitive thing like thumbnails off the ground. If it is a security issue then they could at least document how to set it up on a private instance.



I have the same problem and I find it annoying that we have to install ghostscript in the container… hopefully they fix the docker images soon.

1 Like

I still end up manipulating the new NC docker container after each update.
Had to add ffmpeg to it as well. So far so good.

docker exec -it nextcloud_app_1 su  -s /bin/bash -c 'apt update && apt install imagemagick ffmpeg -y'

Something seems to have changed recently. There is one more hurdle before PDF thumbnails are actually generated.

In /etc/ImageMagick-6/policy.xml
The line
<policy domain="coder" rights="none" pattern="PDF" />
has to be changed to
<policy domain="coder" rights="read|write" pattern="PDF" />

followed by a restart of the php7.4-fpm service or the docker container depending on your env.


And to add something about generating the “correct” preview sizes, check out the link below:

Hope this helps some other lost souls lose less time on this…


After I edited policy.xml I have got the previews, Thanks for the info

1 Like

I’m running ImageMagick 7 on FreeBSD (Nextcloud 20.0.1), but after making the change to the policy I’m still not getting the PDF thumbnails. The error messages continue in the log as below. Any ideas?

[core] Error: ImagickException: Failed to read the file at <<closure>>

 0. /usr/local/www/nextcloud/lib/private/Preview/Bitmap.php line 87
 1. /usr/local/www/nextcloud/lib/private/Preview/Bitmap.php line 50
    OC\Preview\Bitmap->getResizedPreview("/tmp/oc_tmp_sIn0ux", 1024, 1024)
 2. /usr/local/www/nextcloud/lib/private/Preview/GeneratorHelper.php line 63
    OC\Preview\Bitmap->getThumbnail(OC\Files\Node\File {}, 1024, 1024)
 3. /usr/local/www/nextcloud/lib/private/Preview/Generator.php line 244
    OC\Preview\GeneratorHelper->getThumbnail(OC\Preview\PDF {}, OC\Files\Node\File {}, 1024, 1024)
 4. /usr/local/www/nextcloud/lib/private/Preview/Generator.php line 140
    OC\Preview\Generator->getMaxPreview(OC\Files\SimpleFS\SimpleFolder {}, OC\Files\Node\File {}, "application/pdf", "")
 5. /usr/local/www/nextcloud/lib/private/Preview/Generator.php line 109
    OC\Preview\Generator->generatePreviews(OC\Files\Node\File {}, [{width: 500,hei ... }], "application/pdf")
 6. /usr/local/www/nextcloud/lib/private/PreviewManager.php line 190
    OC\Preview\Generator->getPreview(OC\Files\Node\File {}, 500, 500, true, "fill", null)
 7. /usr/local/www/nextcloud/core/Controller/PreviewController.php line 170
    OC\PreviewManager->getPreview(OC\Files\Node\File {}, 500, 500, true, "fill")
 8. /usr/local/www/nextcloud/core/Controller/PreviewController.php line 143
    OC\Core\Controller\PreviewController->fetchPreview(OC\Files\Node\File {}, 500, 500, false, false, "fill")
 9. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 218
    OC\Core\Controller\PreviewController->getPreviewByFileId(3028025, 500, 500, false, false, "fill")
10. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 127
    OC\AppFramework\Http\Dispatcher->executeController(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
11. /usr/local/www/nextcloud/lib/private/AppFramework/App.php line 157
    OC\AppFramework\Http\Dispatcher->dispatch(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
12. /usr/local/www/nextcloud/lib/private/Route/Router.php line 302
    OC\AppFramework\App::main("OC\\Core\\Controller\\PreviewController", "getPreviewByFileId", OC\AppFramework\ ... {}, {_route: "core.P ... "})
13. /usr/local/www/nextcloud/lib/base.php line 993
14. /usr/local/www/nextcloud/index.php line 37

GET /core/preview?fileId=3028025&c=608159bd8706a&x=500&y=500&forceIcon=0&a=0
from by user at 2021-04-22T07:11:12-04:00