介绍
我有一个带有 GUI 的 docker 容器,我在其中通过 LibreOffice Calc 注册了我的宏。使用 docker 容器提供的 GUI,我可以通过命令行成功运行宏。但是,当我在 Kubernetes Pod 中加载图像时,当我尝试运行宏时,它会无限期挂起。
这是宏:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">REM ***** BASIC *****
Sub FitToPage
Dim document As Object, pageStyles As Object
document = ThisComponent
pageStyles = document.StyleFamilies.getByName("PageStyles")
For i = 0 To Document.Sheets.Count - 1
Dim sheet As Object, Style As Object
sheet = document.Sheets(i)
style = pageStyles.getByName(sheet.PageStyle)
style.ScaleToPagesX = 1
style.ScaleToPagesY = 999
Next
On Error Resume Next
document.storeSelf(Array())
document.close(true)
End Sub
</script:module>
运行宏命令:
soffice --headless --nologo --nofirststartwizard --norestore macro://Standard.Module1.FitToPage <file>.xlsx
奇怪的是,我能够很好地运行其他无头 libreoffice 命令。例如,如果我尝试将文件转换为 pdf 而不使用更改缩放比例soffice --headless --nologo --nofirststartwizard --norestore --convert-to pdf --outdir . <file>.xlsx
,那么 soffice 运行得非常好。
其他信息:
- Ubuntu 18.04
- 我实例化并以root身份运行libre。
- 该模块是通过 LibreOffice Calc 加载的。
- 该模块可以在 中找到
~/.config/libreoffice/4/user/basic/Standard/Module1.xba
。 - 我有其他 Pod 在集群中运行就好了
- 我没有为集群中的 docker 镜像配置 GUI
- 我正在向其中倾倒资源(
15Gi mem, 15 CPU
)
结论
任何帮助都将不胜感激。我可以根据要求提供所需的更多信息。
更新
对我来说,soffice &
在运行宏之前在后台运行它似乎可行。这可能与 libreoffice 如何处理其状态有关?
无论如何,这都不是一个完美的解决方案,所以我将把它打开,以防有人有更好的解决方案。