PDF Preview not working
ZeeSarp opened this issue ยท 10 comments
ownCloud 10.14.0 (stable, docker image, arm64)
I added mappings to the docker-compose.yml, so my changes to the config.php are persisted:

I added the required elements to the array in the config.php:

But after starting the container, there were no pdf previews to be seen.

I also added <policy domain="coder" rights="none" pattern="PDF" /> as a subnode of <policymap> to the policy.xml, but it was neither ImageMagick version 6, nor located at /etc/ImageMagick-6/policy.xml.
Found it at "/usr/local/etc/ImageMagick-7/policy.xml".
Also, the version wasn't 3.4 but 3.7 instead.
Is the documentation outdated, or is my container weird?
Am I missing a step here?
Steps to reproduce
- Deploy owncloud containers
- Add PDF provider to config.php
- Upload pdf document
Expected behaviour
The web UI requests and displays a preview for pdf files.
Actual behaviour
The web UI does not request, nor does it display a preview for pdf files

Server configuration
Operating system:
debian as docker host
Web server:
No idea, probably apache2
Database:
Also no idea.
Docker compose specifies both a container for redis and for mariadb
PHP version:
phpinfo()
PHP Version => 7.4.3-4ubuntu2.20
ownCloud version: (see ownCloud admin page)
10.14.0
Updated from an older ownCloud or fresh install:
fresh install
Where did you install ownCloud from:
dockerhub
Signing status (ownCloud 9.0 and above):
"No errors have been found."
The content of config/config.php:
Default config.php, except for the two added elements visible in the screenshot above.
List of activated apps:
Can't successfully execute "php occ app:list". Produces lots of exceptions.
gist
Are you using external storage, if yes which one: local/smb/sftp/...
no
Are you using encryption: yes/no
no
Client configuration
Browser:
Edge
Operating system:
Windows 11
Logs
ownCloud log (data/owncloud.log)
does not exist
I have entries in "enabledPreviewProviders" like:
'OC\\Preview\\PDF'
Maybe you need to put double-backslash in the single-quoted strings to actually specify a literal backslash
https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single
"To specify a literal single quote, escape it with a backslash (). To specify a literal backslash, double it (\). "
Good point, forgot about escaping tbh.
But according to the php documentation that should not be necessary.
I tried it anyway (changed config.php and redeployed, logged into owncloud again, navigated to a folder with pdf and refreshed the page), but that did not seem to help.
The web page still does only send preview requests to the api for the png i uploaded, and ignores the pdf.
If I recall correctly, the web page did send request fpr pdfs as well in 10.12.
Ist there anything that i need to configure to make the web page request previews for pdfs?
from my understanding you need to apply any configuration change via env variables.
editing config.php directly (even when being mounted) is not how the docker images are intended to be used.
please give it a try by setting these env vars:
- OWNCLOUD_ENABLED_PREVIEW_PROVIDERS
- OWNCLOUD_ENABLE_PREVIEWS
I also added
<policy domain="coder" rights="none" pattern="PDF" />as a subnode of<policymap>to the policy.xml, but it was neither ImageMagick version 6, nor located at /etc/ImageMagick-6/policy.xml.
Found it at "/usr/local/etc/ImageMagick-7/policy.xml".
Also, the version wasn't 3.4 but 3.7 instead.
Is the documentation outdated, or is my container weird?
Docs are referring to standard Ubuntu based setups. The docker image has necessary changes already applied
Most likely a duplicate of #41185 and most likely Docker image specific (PDFs ware working for me on 10.14.0) as these just don't provide the required support like stated in owncloud/docs-server#1269:
E.g.: Currently our docker image have an imagick that neither supports SVG nor PDF.
Tried the environment variable approach (without manually editing the config.php and without mappings), but the underlying issue seems to be the same as in the issue iasdeoupxe mentioned.

If I understood the code correctly, the missing PDF support is the reason for the missing preview requests, as PDF is not registered in PreviewManager.php registerCoreProviders, so "oc_appconfig.core.enabledPreviewProviders" in filelist.js will never contain the PDF mime type and thus not try to load a preview.
Would it be possible to output a warning or an error when a provider that is specified in config.php is not available?
And is there a way to enable pdf support or to obtain a version of ImageMagick with pdf support?
Nevermind!
Just found out that the imagemagick lib requires ghostscript in order to convert PDF files.
In the owncloud php base image this is explicitly uninstalled.

Wasn't too sure if ghostscript depends on gsfonts and ffmpeg, so I installed all of them.
Now I have 231 enabled providers instead of 230 (PDF is one of them) and the previews work:

Could this be added to the documentation?
As far as I am concerned this issue can be closed.
Thank you for your help!
Could this be added to the documentation?
The previous posting sounds to me more like you should raise an issue over at https://github.com/owncloud-docker/php/issues as this looks really Docker specific.
Otherwise creating an issue at https://github.com/owncloud/docs-server/issues would be required.
Thanks, will do
Should be fixed by owncloud-docker/php#164. Thanks for reporting.
@ZeeSarp We deployed fixed docker images for 10.13.4 and 10.14.0. Please try e.g.
docker pull owncloud/server:10.14.0
docker run --rm -ti -p 8080:8080 -e 'OWNCLOUD_ENABLED_PREVIEW_PROVIDERS=OC\Preview\PDF,OC\Preview\SGI,OC\Preview\Heic,OC\Preview\PNG,OC\Preview\JPEG,OC\Preview\WEBP,OC\Preview\GIF,OC\Preview\BMP,OC\Preview\XBitmap,OC\Preview\MP3,OC\Preview\TXT,OC\Preview\MarkDown,OC\Preview\SVG' owncloud/server:10.14.0
All kinds of previews work nicely for me.