LibreOffice 7.2.2.2 afc8349a712d40a424b5a12dcfa54f843620fa62
OS: alpine linux docker image
basic macro .
REM ***** BASIC *****
function OpenSilent(FilePath as String) as Object
Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "Hidden"
FileProperties(0).Value = True
Dim Dummy()
OpenSilent = StarDesktop.loadComponentFromURL(ConvertToURL(FilePath), "_blank", 0, Dummy())
end function
sub Headless(FilePath as String,Out as String)
Document = OpenSilent(FilePath)
call ChangeScale()
ToPDF(Out)
call Document.close(True)
end sub
sub ChangeScale
oStyleFamilies = ThisComponent.StyleFamilies
oPageStyles = oStyleFamilies.getByName("PageStyles")
numStyle = oPageStyles.Count
For iCount = 0 To numStyle-1
oDefaultStyle = oPageStyles(iCount)
oDefaultStyle.PageScale = 50
Next iCount
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
end sub
function ToPDF(File as String)
dim args(0) As New "com.sun.star.beans.PropertyValue"
args(0).Name = "FilterName"
args(0).Value = "calc_pdf_Export"
ThisComponent.storeToURL(ConvertToURL(File),args())
end function
execute command line
soffice --invisible --nofirststartwizard --headless --norestore ‘macro:///Standard.Module1.Headless("/xxx.xlsx","/test.pdf")’
then nothing happened.
When execute command soffice 'macro:///Standard.Module1.Headless("/xxx.xlsx","/test.pdf")'
got a error msg: Failed to open display .
Except output a pdf after execute the macro