Seafile 专业版服务器支持在线预览 office 文件,配置方法如下。

安装 Libreoffice/UNO

Office 预览依赖于 Libreoffice 4.1+ 和 Python-uno 库。

Ubuntu/Debian:

  1. sudo apt-get install libreoffice libreoffice-script-provider-python poppler-utils
For older version of Ubuntu: sudo apt-get install libreoffice python-uno

Centos/RHEL:

  1. sudo yum install libreoffice libreoffice-headless libreoffice-pyuno poppler-utils

其他 Linux 发行版可以参考: Installation of LibreOffice on Linux

你还需要安装字体文件:

Ubuntu/Debian:

  1. # For ubuntu/debian
  2. sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy

CentOS:

  1. # For CentOS
  2. sudo yum install wqy-microhei-fonts wqy-zenhei-fonts wqy-unibit-fonts -y

开启配置项

  • 打开 conf/seafevents.conf, 添加:
    [OFFICE CONVERTER]
    enabled = true
  • 保存后 seafevents.conf 重启 Seafile 服务 ./seafile.sh restart

    其他配置选项

  1. [OFFICE CONVERTER]
  2. ## How many libreoffice worker processes to run concurrenlty
  3. workers = 1
  4. ## where to store the converted office/pdf files. Deafult is /tmp/.
  5. outputdir = /tmp/
  6. ## how many pages are allowed to be previewed online. Default is 50 pages
  7. max-pages = 50
  8. ## the max size of documents to allow to be previewed online, in MB. Default is 2 MB
  9. ## Preview a large file (for example >30M) online will freeze the browser.
  10. max-size = 2

FAQ

Office 预览不能工作,日志文件在哪?

你可以查看 logs/seafevents.log

Office 预览不能工作的一个可能原因是你的机器上的 libreoffice 版本太低,可以用以下方法修复

删除安装的 libreoffice:

  1. sudo apt-get remove libreoffice* python-uno python3-uno

从官网下载最新版 libreoffice official site,并安装

  1. tar xf LibreOffice_4.1.6_Linux_x86-64_deb.tar.gz
  2. cd LibreOffice_4.1.6.2_Linux_x86-64_deb
  3. cd DEBS
  4. sudo dpkg -i *.deb

重启 Seafile 服务

  1. ./seafile.sh restart

原文: https://manual-cn.seafile.com/deploy_pro/office_documents_preview.html