Determining PDF Export Options
Posted: Mon Aug 14, 2023 4:49 pm
The PDF export options are not very well documented and difficult to find in the source code. The below macro calls the PDF dialog from a calc document and writes the options you set into the first sheet.
The available export parameters are also listed for information for AO and LO.
The available export parameters are also listed for information for AO and LO.
Code: Select all
Sub GetFilterdataFromPdfExportDialog
oDoc = ThisComponent
oo = createUnoService("com.sun.star.document.PDFDialog")
oo.setSourceDocument(oDoc)
oo.execute()
oProp = oo.PropertyValues(0)
if oProp.Name <> "FilterData" then
msgbox "Houston ..."
exit sub
endif
OOoReflection = CreateUnoService("com.sun.star.reflection.CoreReflection") 'copied that from the great Xray ...
oSheet = ThisComponent.Sheets.getByIndex(0)
oSheet.clearContents(com.sun.star.sheet.CellFlags.VALUE + com.sun.star.sheet.CellFlags.DATETIME + com.sun.star.sheet.CellFlags.STRING + com.sun.star.sheet.CellFlags.FORMULA)
args = oProp.Value
for k=0 to UBound(args)
arg = args(k)
if (arg.Name <> "") then
oSheet.getCellByPosition(0, k).setFormula(arg.Name)
sType = OOoReflection.getType(arg.Value).Name
if (sType="byte") or (sType="string") or (sType="boolean") or (sType="int") or (sType="long") then
oSheet.getCellByPosition(1, k).setString(arg.Value)
endif
oSheet.getCellByPosition(2, k).setString(sType)
endif
next
End Sub