Seafile Professional Server supports previewing office/pdf documents online by converting them to HTML pages. You can follow these steps to use the feature. If you’d like to edit office files online, you can integrate Seafile with Microsoft Office Online server, LibreOffice online or OnlyOffice.

Install Libreoffice/UNO

Libreoffice 4.1+ and Python-uno library are required to enable office files online preview.

On Ubuntu/Debian:

  1. sudo apt-get install libreoffice libreoffice-script-provider-python

For older version of Ubuntu: sudo apt-get install libreoffice python-uno

On Centos/RHEL:

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

For other Linux distributions: Installation of LibreOffice on Linux

Also, you may need to install fonts for your language, especially for Asians, otherwise the office/pdf document may not display correctly.

For example, Chinese users may wish to install the WenQuanYi series of truetype fonts:

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

Install poppler-utils

The package poppler-utils is also required.

On Ubuntu/Debian:

  1. sudo apt-get install poppler-utils

On CentOS/Red Hat:

  1. sudo yum install poppler-utils

Enable Office Preview

  1. Open file seafevents.conf, in the OFFICE CONVERTER section:
    1. [OFFICE CONVERTER]
    2. enabled = true
  2. After modifying and saving seafevents.conf, restart seafile server by ./seafile.sh restart
  3. Open a doc/ppt/xls/pdf file on seahub, you should be about the previewing it in your browser.

Other Configurable Options

Here are full list of options you can fine tune:

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

FAQ about Office/PDF document preview" class="reference-link">FAQ about Office/PDF document preview

  • Document preview doesn’t work, where to find more information?

    You can check the log at logs/seafevents.log

  • My server is CentOS, and I see errors like “/usr/lib64/libreoffice/program/soffice.bin X11 error: Can’t open display”, how could I fix it?

    This error indicates you have not installed the libreoffice-headless package. Install it by "sudo yum install libreoffice-headless".

  • How can I change max size and max pages of documents that can be previewed online ?

    1. Locate the OFFICE CONVERTER section in seafevents.conf.
    2. Append following lines to the section
      1. # the max size of documents to allow to be previewed online, in MB. Default is 2 MB
      2. max-size = 2
      3. # how many pages are allowed to be previewed online. Default is 50 pages
      4. max-pages = 50

Then, restart seafile server

  1. cd /data/haiwen/seafile-server-latest/
  2. ./seafile.sh restart
  3. ./seahub.sh restart
  • Document preview doesn’t work on my Ubuntu/Debian server, what can I do?

Current office online preview works with libreoffice 4.0-4.2. If the version of libreoffice installed by apt-get is too old or too new, you can solve this by:

Remove the installed libreoffice:

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

Download libreoffice packages from libreoffice official site

Install the downloaded pacakges:

  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

Restart your seafile server and try again. It should work now.

  1. ./seafile.sh restart
  • The browser displays “document conversion failed”, and in the logs I see messages like [WARNING] failed to convert xxx to ..., what should I do?

    Sometimes the libreoffice process need to be restarted, especially if it’s the first time seafile server is running on the server.

    Try to kill the libreoffice process:

    1. pkill -f soffice.bin

    Now try re-opening the preview page in the brower again.

    Also if you are deploying seafile in cluster mode, make sure memcached is working on each server.

  • The above solution does not solve my problem.

    Please check whether the user you run Seafile can correctly start the libreoffice process. There may be permission problems. For example, if you use www-data user to run Seafile, make sure www-data has a home directory and can write to the home directory.