libreoffice converts office files such as ppt, xls, doc to pdf

First install the libreoffice software:

http://zh-cn.libreoffice.org/

Then click download--stable version, and download it according to the operating system, such as centos, download the rpm package, both 32-bit and 64-bit.

Then unzip it, enter the directory, and use the rpm command to install, for example:

cd LibreOffice_5.2.4.2_Linux_x86-64_rpm/

cd RPMS

rpm -ivh *

 

Paste the command usage:

export DISPLAY=:0.0 && libreoffice --headless --invisible --convert-to pdf --outdir /root/out/ /root/xls.xls

The last parameter here is the absolute path of the file, and the parameter after --outdir is the directory where the converted pdf file is saved. The final file absolute path can also be placed before --outdir.

for example:

export DISPLAY=:0.0 && libreoffice --headless --invisible --convert-to pdf /root/xls.xls --outdir /root/out/

 

What needs to be mentioned here is that the fonts in windows must be copied to the font file directory of the linux server, otherwise the Chinese will be horrible after conversion! !

 For example, I copied all the fonts in the font directory of windows to a folder msfonts, then packaged the entire folder and transferred it to the linux server, decompressed it, and moved it to /usr/share/fonts/. If the office you use is a lite version, you also need to download a 125MB compressed package of office2010 font package and download, and put all the fonts in msfonts.

 

After the font is ready, execute the following command to update the font cache:

fc-cache -fv

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326871334&siteId=291194637