libreoffice – 业余语言练习

libreoffice

root135@root135:~/Downloads/LibreOffice_25.2.0.3_Linux_x86-64_deb$ pwd
/home/root135/Downloads/LibreOffice_25.2.0.3_Linux_x86-64_deb
sudo dpkg -i /home/root135/Downloads/LibreOffice_25.2.0.3_Linux_x86-64_deb/DEBS/
安装完成之后,命令行libreoffice会出现bash: libreoffice: command not found
whereis
root135@root135:~$ whereis libreoffice
libreoffice: /etc/libreoffice /usr/local/bin/libreoffice
root@root135:/usr/local/bin# ls -lth
total 36K
lrwxrwxrwx 1 root root 36 Jan 24 20:32
libreoffice25.2 -> /opt/libreoffice25.2/program/soffice
-rwxr-xr-x 1 root staff 233 Nov 6 20:01 normalizer
-rwxr-xr-x 1 root staff 214 Nov 6 20:01 pyspnego-parse
-rwxr-xr-x 1 root staff 216 Nov 1 15:59 f2py
-rwxr-xr-x 1 root staff 216 Nov 1 15:59 f2py3
-rwxr-xr-x 1 root staff 216 Nov 1 15:59 f2py3.7
-rwxr-xr-x 1 root staff 224 Nov 1 15:58 pip
-rwxr-xr-x 1 root staff 224 Nov 1 15:58 pip3
-rwxr-xr-x 1 root staff 224 Nov 1 15:58 pip3.10
-rwxr-xr-x 1 root staff 224 Nov 1 15:58 pip3.7
lrwxrwxrwx 1 root staff 15 Oct 2 09:07 libreoffice -> libreoffice24.8
root@root135:/usr/local/bin# mv libreoffice libreoffice-bk
root@root135:/usr/local/bin# mv libreoffice25.2 libreoffice
root@root135:/usr/local/bin#

也可以创建软链接:ln -s /usr/local/bin/libreoffice25.2 /usr/local/bin/libreoffice

root135@root135:~$ libreoffice --writer
javaldx: Could not find a Java Runtime Environment!
Warning: failed to read path from javaldx
(soffice:5827): dbind-WARNING **: 10:23:13.575:
Error retrieving accessibility bus address:
org.freedesktop.DBus.Error.ServiceUnknown:
The name org.a11y.Bus was not provided by any .service files
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
-----------------------------
libreoffice --help
New document creation arguments: 
The arguments create an empty document of specified kind. Only one of them may 
be used in one command line. If filenames are specified after an argument, 
then it tries to open those files in the specified component. 
--writer Creates an empty Writer document. 
--calc Creates an empty Calc document. 
--draw Creates an empty Draw document. 
--impress Creates an empty Impress document. 
--base Creates a new database. 
--global Creates an empty Writer master (global) document. 
--math Creates an empty Math document (formula). 
--web Creates an empty HTML document.
1.对于.doc、.docx、.odt等文档格式,你可以使用libreoffice命令配合--convert-to和--headless选项。
libreoffice --headless --convert-to pdf your_document.docx
2.使用LibreOffice Calc转换电子表格为PDF
对于.xls、.xlsx、.ods等电子表格格式,可以使用类似的方法:
libreoffice --headless --convert-to pdf your_spreadsheet.xlsx
3.使用LibreOffice Impress转换演示文稿为PDF
对于.ppt、.pptx、.odp等演示文稿格式,同样可以使用:
libreoffice --headless --convert-to pdf your_presentation.pptx
注意事项:
--headless选项使得LibreOffice在后台运行,不显示GUI界面。这对于自动化脚本特别有用。
你可以通过添加--outdir选项来指定输出目录,例如:
libreoffice --headless --convert-to pdf --outdir /path/to/output your_document.docx
如果你的文件名或路径包含空格,确保整个命令用引号(单引号或双引号)包围,例如:
libreoffice --headless --convert-to pdf "your document.docx"
这些命令行方法使得在Linux环境下使用LibreOffice转换文件为PDF变得非常简单和高效。
Published
Categorized as linux

Leave a comment

Your email address will not be published. Required fields are marked *