Determining PDF Export Options

Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This section is not for asking questions about writing your own macros.
Post Reply
ms777
Volunteer
Posts: 177
Joined: Mon Oct 08, 2007 1:33 am

Determining PDF Export Options

Post by ms777 »

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.

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
Attachments
PDFDialog.ods
(25.65 KiB) Downloaded 221 times
JPL
Volunteer
Posts: 132
Joined: Fri Mar 30, 2012 3:14 pm

Re: Determining PDF Export Options

Post by JPL »

Detailed and IMO excellent info about the PDF export options can be found on next page of the OpenOffice wiki :

https://wiki.openoffice.org/wiki/API/Tu ... PDF_export

Thanks anyway for your code.
Kubuntu 22.04 / LibO 24.2
Access2Base (LibO).
BaseDocumenter extension (LibO)
ScriptForge (LibO)
Documentation on https://help.libreoffice.org/latest/en- ... bPAR=BASIC
ms777
Volunteer
Posts: 177
Joined: Mon Oct 08, 2007 1:33 am

Re: Determining PDF Export Options

Post by ms777 »

@JPL,

thanks for the wiki page. I should do more thorough search before posting ...

In an LO forum post https://ask.libreoffice.org/t/java-uno- ... port/94613, mikekaganski gave also this reference for LO pdf export options: https://help.libreoffice.org/master/en- ... arams.html
Post Reply