LibreOffice to build and deploy automation scripts under Centos7
Introduction to LibreOffice
LibreOffice is a powerful office suite - it's clear interface and powerful tool that allows you to unleash your creativity and increase your productivity.
Free free, all-powerful, cross-platform office suite
LibreOffice is a free open-source office software all-around free, runs on Microsoft Windows, GNU / Linux and other operating systems as well as macOS. It includes Writer, Calc, Impress, Draw, Math and Base and other components, can be used for text documents, spreadsheets, slide presentations, drawings, documents, mathematical formulas editor, database management, etc., respectively.
LibreOffice uses for businesses and individuals are free GPL 2.0 license. You can freely distribute the software without paying licensing fees (but you can still pay to get certified professional support). It's completely open source code, anyone can participate in the development and maintenance of the software.
It supports a variety of document formats
LibreOffice supports a variety of file formats. In addition to its native support for the Open Document Format (OpenDocument Format, ODF), it also supports a number of non-open format, such as Microsoft Microsoft® Word, Excel, PowerPoint and Publisher of formats.
Scalability
LibreOffice supports extensions. You can use LibreOffice Basic, Python, C / C ++, Java and other programming languages for the development of LibreOffice extensions to enrich its functionality. LibreOffice extensions software library has more extensions available.
In addition, it also supports template, you can use LibreOffice template library in an existing template, or create your own templates.
Based on a powerful gene
LibreOffice, formerly known as OpenOffice.org , while OpenOffice.org was originally based on StarOffice. It is after many years of development and accumulation, and has been used by many users worldwide. Today, LibreOffice is the most active of the OpenOffice.org code base successor, every six months to release a major new version.
Overall, LibreOffice interface of Microsoft Office is not so gorgeous, but very simple and practical. Its six components corresponding to the Office no less, but also less demanding on system configuration, small footprint.
[root@Libreoffice~]# vi /etc/fonts/fonts.conf
#找到 Font directory list 字体列表,将目录改成/chinese下
<dir>/usr/share/fonts/chinese</dir> ##更改后
:wq 保存并推出
[root@Libreoffice~]# fc-cache
[root@Libreoffice~]# fc-list
Then you can use the command to convert
If you want to deploy a script to automate the conversion of how to do it? Because a dedicated server with the NFS mount to make the conversion, the script has been open state, where we wrote while an endless loop;
Environment: Centos7.6
The mount directory / opt / docx
Developers upload .docx file to opt / directory under its shared via NFS hang on to / docx
Will be converted into pdf files with complete conversion of docx file to a folder name / opt / files in a folder as today's date
Script as follows
[root@ceshi2~]# vi libreoffice.sh
#/bin/bash ##解释器
#author ouliwei ##作者
#date 2019.6.10 ##完成时间
whiletrue ##while死循环
dofor i in /opt/docx/*.docx ;do
if [[ -f $i ]];then ##if判断是否有docx文件
if [[ -d /opt/$(date +%F) ]];then ##if判断是否有时间目录
soffice --headless --convert-to pdf $i --outdir /opt/$(date +%F)
mv $i /opt/$(date +%F)
else
mkdir /opt/$(date +%F) ##如果没有先创建
soffice --headless --convert-to pdf $i --outdir /opt/$(date +%F)
mv $i /opt/$(date +%F) ##移动已经转换完成的文件
fi
else
sleep 60 ##如果没有docx文件 则休眠一分钟(一分钟后再次从第一步开始)
fi
done
done
[root@ceshi2 ~]# chmod +x libreoffice.sh ##加执行权限
[root@ceshi2 ~]# ./libreoffice.sh ##执行脚本