How to make libreoffice headless to work on CentOS 6.3

以下技术应用于最优质的水果的鲜果篮

In the latest days I was wondering how to make a minimal file-server able to convert some documents readable from LibreOffice to PDF.

The first thing I’ve done was to install a Virtual Machine with CentOS 6.3 Minimal (No serverX, no WebServer… just, network and few other functionalities).

This post can be followed simply both by an high skilled user and by a dummy user. All steps are well documented and each command is adequatelly described.

Installation

Traveling through the yum repositories, I’ve found the libreoffice-headless (it means the openoffice without ServerX) then I’ve installed it using this simple command:

root@centos:/$ yum install libreoffice-headless

it should install all requirements, dependencies and then libreoffice 3.4 headless. It means the functionality to make LibreOffice to work on command line.

I’ve thought: “well I’ve done all I need… too easy!!!” so I’ve run the command:

root@centos:/$ libreoffice --headless --convert-to pdf mydocument.odt

The above command will convert the document from ODT format to PDF. The server freezes few seconds, the HD Led flashes two or three times and then the shell prompt was available again.

Great! I did a ls command but the pdf file wasn’t there… “Oh Damn!!!

Someone in the Web suggest to use JODconvertersomeothers told that it is a bug of Libreoffice.

I found the solution without installing third-part software onto your minimal OS instead.

Just installing the writer will solve all your prolbems:

root@centos:/$ yum install libreoffice-writer

then after the OS has finished the installation process, run again

root@centos:/$ libreoffice --headless --convert-to pdf mydocument.odt

As you can notice you’ve done!

More document types

To enable PPT/ODP and XLS/ODS conversion you need to install either libreoffice-impress and libreoffice-calc packages with following commands:

root@centos:/$ yum install libreoffice-impress
root@centos:/$ yum install libreoffice-calc

Using a listner

Sometimes if you have several applications that need to convert documents on the fly and them are not installed on the same Server, you could consider to use the LibreOffice  headless with a listner on a Converter Server.

root@centos:/$ libreoffice --headless --accept="socket,host=0,port=8100,tcpNoDelay=1;urp" --nodefault --nofirststartwizard --nolockcheck --nologo --norestore --invisible &

In this way another server can connect to the LibreOffice listner through the UNO API  on the defined port. Let’s describe most of the above parameters:

  • –accept Specify a UNO connect-string to create a UNO acceptor through which other programs can connect to access the API. In the above case it creates the acceptor on the port 8001 of this server (localhost).
  • –nodefault tells that no default document must be created at startup.
  • –nolockcheck disables the check for remote instances using the installation.
  • –nologo Disables the splash screen at program start.
  • –norestore Disables restart and file recovery after a system crash. It is possible that LO will try to restore a file it keeps crashing on, if that happens –norestoreis the only way to start LO.
  • –nosplash Disables the splash screen at program start.
  • –invisible This prepares Libreoffice to be used as service because it’s available but not visible in background.

The last & is not a typing error: it tells the shell “do not wait for the end of the task, execute it and let me use the shell again”: simply “Multitasking” :-)

I want to know more

Most of the above details are reported from the man page of LibreOffice.

root@centos:/$ man libreoffice

More commands, options and features are heavly described there, some others less but it’s the best starting point!

And now? Have fun with document conversion! :-)


Edit: 

Install language support for Centos:

yum groupinstall "Chinese Support", yum groupinstall "Japanese Support", yum groupinstall "Korean Support".

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值