美文网首页
「Centos7」安装LibreOffice教程+Python使

「Centos7」安装LibreOffice教程+Python使

作者: an鑫_wolfxin2010 | 来源:发表于2020-09-27 15:53 被阅读0次

    安装依赖库

    执行 libreoffice6.0 可能会提示库文件找不到,如 libcairo.so.2,libcups.so.2,libSM.so.6 等,执行下面几条命令安装需要的库:

    yum install cairo -y
    yum install cups-libs -y
    yum install libSM -y
    

    安装LibreOffice

    cd /tmp/
    mkdir libreoffice
    cd ./libreoffice/
    # 安装LibreOffice7.0.1
    # 如果您需要下载其他版本,请参阅:http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/
    wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.0.1/rpm/x86_64/LibreOffice_7.0.1_Linux_x86-64_rpm.tar.gz
    tar -xzvf LibreOffice_7.0.1_Linux_x86-64_rpm.tar.gz
    cd LibreOffice_7.0.1.2_Linux_x86-64_rpm/RPMS
    yum localinstall *.rpm
    
    # 安装LibreOffice7.0.1 SDK
    cd /tmp/libreoffice/
    wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.0.1/rpm/x86_64/LibreOffice_7.0.1_Linux_x86-64_rpm_sdk.tar.gz
    tar -xzvf LibreOffice_7.0.1_Linux_x86-64_rpm_sdk.tar.gz
    cd LibreOffice_7.0.1.2_Linux_x86-64_rpm_sdk/RPMS
    yum localinstall *.rpm
    
    # 安装LibreOffice7.0.1中文语言包
    cd /tmp/libreoffice/
    wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.0.1/rpm/x86_64/LibreOffice_7.0.1_Linux_x86-64_rpm_langpack_zh-CN.tar.gz
    cd LibreOffice_7.0.1.2_Linux_x86-64_rpm_langpack_zh-CN/RPMS
    yum localinstall *.rpm
    

    查看LibreOffice

    which libreoffice7.0 
    # 看到路径:/usr/bin/libreoffice7.0 
    ll /usr/bin/libreoffice7.0 
    # 得到路径:/opt/libreoffice7.0/program/soffice,说明安装成功:/opt/libreoffice7.0 
    #增加软连接
    ln -s /opt/libreoffice7.0/program/soffice /usr/bin/soffice
    

    使用LibreOffice

    import os
    
    im_filename = /tmp/doc/hello.doc""
    out_filepath = "/tmp/doc/temp"
    #将doc文档转换成docx
    os.system("soffice --headless --convert-to docx %s --outdir %s" % (
                                im_filename, out_filepath))
    

    Libreoffice增加字体

    sudo cp simsun.ttc /usr/share/fonts
    cd /usr/share/fonts
    
    # 修改权限
    sudo chmod 644 simsun.ttc
    
    # 更新字体缓存:
    sudo fc-cache -fv
    

    LibreOffice文档

    LibreOffice 能够与 Microsoft Office 系列以及其它开源办公软件深度兼容,且支持的文档格式相当全面

    1. 文本文档:*.odm, *.sgl, *.odt,*.ott, *.sxw, *.stw, *.fodt, *.xml, *.docx,*.docm, *.dotx, *.dotm, *.doc, *.dot, *.wps, *.pdb, *.hwp, *.html, *.htm, *.lwp, *.psw, *.rft, *.sdw, *.vor, *.txt, *.wpd ,*.oth
    2. 电子表格:*.ods, *.ots, *.sxc, *.stc, *.fods, *.xml, *.xlsx, *.xlsm, *.xltm, *.xltx, *.xlsb, *.xls, *.xlc, *.xlm, *.xlw, *.xlk, *.sdc, *.vor, *.dif,*.wk1, *.wks, *.123, *.pxl, *.wb2, *.csv
    3. 演示文稿:*.odp, *.otp, *.sti, *.sxd, *.fodp, *.xml, *.pptx, *.pptm, *.ppsx, *.potm, *.potx, *.ppt, *.pps, *.pot, *.sdd, *.vor, *.sdp
    4. 绘图:*.odg, *.otg, *.sxd, *.std, *.sgv,*.sda, *.vor, *.sdd, *.cdr, *.svg, *.vsd, *.vst
    5. 网页:*.html, *.htm, *.stw
    6. 主控文档:*.sxg
    7. 公式:*.odf, *.sxm, *.smf, *.mml

    相关文章

      网友评论

          本文标题:「Centos7」安装LibreOffice教程+Python使

          本文链接:https://www.haomeiwen.com/subject/wgkluktx.html