如何在Python + Windows上使用LibreOffice API(UNO)?

问题描述 投票:0回答:1

此问题专注于Windows + LibreOffice + Python 3。

我还安装了LibreOffice(6.3.4.2),pip install unoconvpip install unotoolspip install uno是另一个不相关的库),但是在import uno之后仍然出现此错误:

ModuleNotFoundError:没有名为“ uno”的模块

更一般地说,作为使用UNO的示例,如何使用LibreOffice UNO打开.docx文档并将其导出为PDF?]] >>

几天以来,我对此进行了广泛的搜索,但是我没有找到可重现的示例代码在Windows上运行:

]
python libreoffice openoffice.org uno
1个回答
0
投票

为了与LibreOffice进行交互,请启动在套接字上侦听的实例。我使用的COM并不多,但是我认为这相当于您所要求的COM交互。这可以在命令行上或使用Shell脚本最轻松地完成,但是它也可以使用带有时间延迟和子进程的系统调用来工作。

chdir "%ProgramFiles%\LibreOffice\program\"
start soffice -accept=socket,host=localhost,port=2002;urp;
© www.soinside.com 2019 - 2024. All rights reserved.