【发布时间】:2019-06-02 18:00:42
【问题描述】:
我正在尝试将图像插入到由 unotools 处理/控制的 libreoffice 文档中。
因此我使用以下命令启动 LibreOffice:
soffice --accept='socket,host=localhost,port=8100;urp;StarOffice.Service'
在我的 python 代码中,我可以连接到 LibreOffice:
from unotools import Socket, connect
from unotools.component.writer import Writer
context = connect(Socket('localhost', 8100))
writer = Writer(context)
(此代码取自本文档:https://pypi.org/project/unotools/)
通过使用 writer.set_string_to_end() 我可以在文档中添加一些文本。但是我也想在文档中插入一张图片。到目前为止,我找不到任何完成此操作的资源。图像在我的剪贴板内,所以理想情况下我想直接从那里插入图像。或者,我可以暂时保存图像并插入保存的文件。
是否有任何已知的方法可以使用 unotools 插入图像?任何替代解决方案也会很棒。
【问题讨论】:
标签: python libreoffice uno