Reputation: 31
I have a docker container with a GUI in which I registered my macro through LibreOffice Calc. Using the GUI given by the docker container, I can successfully run the macro via the command line. When I load the image in a Kubernetes Pod, however, the macro hangs indefinitely when I try to run it.
<?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
The strange thing is, I am able to run other headless libreoffice commands just fine. For example, if I were to try to just convert the file to a pdf without changing the scaling using soffice --headless --nologo --nofirststartwizard --norestore --convert-to pdf --outdir . <file>.xlsx
, then soffice runs perfectly fine.
~/.config/libreoffice/4/user/basic/Standard/Module1.xba
.15Gi mem, 15 CPU
)Any help at all would be much appreciated. I can provide any more information required upon request.
For me, running soffice &
to run it in the background before running the macro seemed to work. It might have something to do with how libreoffice handles its state?
This isn't a perfect solution by any means, so I'm going to leave it open in case someone has a better solution.
Upvotes: 1
Views: 2877
Reputation: 772
Your call of the macro is missing a slash /
.
The command line should be
$ soffice --headless --nologo --nofirststartwizard --norestore macro:///Standard.Module1.FitToPage <file>.xlsx
Running in headless mode will obscure any security messages about running macros, simply removing --headless
allows you to check if there are any security messages possibly about running unknown macros that you need to authorsise, before a --headless
run will proceed and complete.
Upvotes: 1