[Solved] Execute macro in command line returns nothing

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
tiendatanduin
Posts: 9
Joined: Fri Dec 15, 2017 1:47 pm

[Solved] Execute macro in command line returns nothing

Post by tiendatanduin »

Hi all,

Following is my macro, which generate a redlined version from two revisions and write the redlining to a pdf. I can execute the macro from within LibreOffice without any issue. However, when I try to execute the macro using command line, no error happens but no output file is generated either. I don't know what's wrong. Could anyone give me a hand?

Here is the command line:

Code: Select all

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --invisible "macro:///tmp/redlining_macro?language=Basic&location=application"
Here is the macro (you should be able to just copy/paste the macro to LibreOffice and execute it):

Code: Select all

sub DocRedlining

dim sUrl as string
dim oDoc as object, oDocFrame as object, dispatcher as object

rem Load the revision file in hidden mode so that there's no UI shown
dim PropVal1(0) as new com.sun.star.beans.PropertyValue
PropVal1(0).Name = "Hidden"
PropVal1(0).Value = true
sUrl = convertToUrl("/tmp/revision.docx")
oDoc = stardesktop.LoadComponentFromURL(sUrl, "_blank", 0, PropVal1())

oDocFrame = oDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem Load the source file to compare against the revision. Note: you must load the revision first, then the source.
dim PropVal2(0) as new com.sun.star.beans.PropertyValue
PropVal2(0).Name = "URL"
PropVal2(0).Value = convertToUrl("/tmp/source.docx")
dispatcher.executeDispatch(oDocFrame, ".uno:CompareDocuments", "", 0, PropVal2())

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ShowTrackedChanges"
args1(0).Value = true
dispatcher.executeDispatch(oDocFrame, ".uno:ShowTrackedChanges", "", 0, args1())

dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "AcceptTrackedChanges"
args2(0).Value = false
dispatcher.executeDispatch(oDocFrame, ".uno:AcceptTrackedChanges", "", 0, args2())

rem Export the redlined to a pdf
dim args3(2) as new com.sun.star.beans.PropertyValue
args3(0).Name = "URL"
args3(0).Value = convertToUrl("/tmp/redlined.pdf")
args3(1).Name = "FilterName"
args3(1).Value = "writer_pdf_Export"
args3(2).Name = "FilterData"
args3(2).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ViewPDFAfterExport",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarks",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportPlaceholders",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportFormFields",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Magnification",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageLayout",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportLinksRelativeFsys",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Watermark",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPasswords",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPermissionPassword",0,Array(),com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureLocation",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureReason",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureContactInfo",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignaturePassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureCertificate",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureTSA",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE))
dispatcher.executeDispatch(oDocFrame, ".uno:ExportToPDF", "", 0, args3())

rem Close the frame
oDocFrame.Close(False)

end sub
Last edited by tiendatanduin on Wed Dec 20, 2017 6:03 am, edited 1 time in total.
LibreOffice 5.2.3.3 and Mac OS X El Capitan
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Execute macro in command line returns nothing

Post by FJCC »

This is just a guess. What happens if you drop the --headless and --invisibe switches?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
tiendatanduin
Posts: 9
Joined: Fri Dec 15, 2017 1:47 pm

Re: Execute macro in command line returns nothing

Post by tiendatanduin »

When dropping the --headless and --invisible, a LibreOffice window will stay open after the command finishes executing, but there still no output file, and the LibreOffice window is completely empty.
LibreOffice 5.2.3.3 and Mac OS X El Capitan
tiendatanduin
Posts: 9
Joined: Fri Dec 15, 2017 1:47 pm

Re: Execute macro in command line returns nothing

Post by tiendatanduin »

So far, I have found that I can invoke the macro if it's inside LibreOffice (e.g. in My Macros & Dialog > Standard > Module1):

Code: Select all

/Applications/LibreOffice.app/Contents/MacOS/soffice --nofirststartwizard --norestore --headless --invisible "macro:///Standard.Module1.DocRedlining()?language=Basic&location=application"
So it seems like the challenge is to either: 1) Find a way to pass in a macro that is not yet presented in LibreOffice; or 2) A way to install a macro into LibreOffice from the command line.

PS: The reason I need to be able to perform all of these actions from command line is that I have a Linux server with LibreOffice installed, and hence GUI is not an option.
LibreOffice 5.2.3.3 and Mac OS X El Capitan
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Execute macro in command line returns nothing

Post by Villeroy »

You can start the office in listening mode and use an ordinary programming language instead of Basic macros.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Execute macro in command line returns nothing

Post by Villeroy »

Just a demo how easy it can be to convert stupid Basic macros into a useful stand-alone Python program.

1) I fired up a simple text editor with syntax highlighting, created a new Python module redlining.py with a helper class Office() and made it executable (chmod +x redlining.py).

2) I pasted the Basic macro, walked through it carefully line by line, did some syntax editing here, some find/replace there. Python has a Basic like syntax. The code consists of calls to the UNO-API and this API is almost identical in Basic and Python. The Office class takes care of the rest.

The very first line starting with #! declares the Python runtime which provides an uno module. for LibreOffice installed from the repos it could be the default Python3 (e.g. #!/usr/bin/python3) or it may be some Python runtime installed together with another LibreOffice (e.g. #!/opt/libreoffice5.4/program/python).

3) Start LibreOffice in listening mode, listening to external programs on port 2002:

Code: Select all

libreoffice5.4 --accept="socket,host=localhost,port=2002;urp;" --norestore --nologo --nodefault --headless &
4) run the Python script:

Code: Select all

/tmp/redlining.py
The script executes the 2 last lines. First line instanciating a helper object for the listening office instance. Second line passed the Office object to the routine DocRedlining.

Code: Select all

#!/opt/libreoffice5.4/program/python

import uno
from com.sun.star.beans.PropertyState import DIRECT_VALUE
# just in case you need to call Office.msgbox
from com.sun.star.awt.MessageBoxType import MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX
from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_ABORT_IGNORE_RETRY, BUTTONS_YES_NO_CANCEL, BUTTONS_YES_NO, BUTTONS_RETRY_CANCEL, DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE
from com.sun.star.awt.MessageBoxResults import CANCEL, OK, YES, NO, RETRY, IGNORE

class Office:
    '''Frequently used office objects and useful methods'''
    def __init__(self, local_context = uno.getComponentContext(), connect_string = ''):
        if connect_string:
            resolver = local_context.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local_context )
            self.ctx = ctx = resolver.resolve(connect_string)
        else:
            self.ctx = local_context
        self.smgr = self.ctx.getServiceManager()
        self.tk = self.smgr.createInstance('com.sun.star.awt.Toolkit')
        self.StarDesktop = self.smgr.createInstance('com.sun.star.frame.Desktop')
        self.win = None

    def getDocument(self):
        return self.StarDesktop.CurrentFrame.Controller.getModel()
        
    def createUnoService(self, name,):
        return self.smgr.createInstance(name)
                
    def getURLStruct(self, sURL):
        url = uno.createUnoStruct('com.sun.star.util.URL')
        srv = self.createUnoService('com.sun.star.util.URLTransformer')
        url.Complete = sURL
        x = uno.invoke(srv,"parseStrict",(uno.Any('com.sun.star.util.URL',url),))
        return x[0]==True and x[1] or Null        
        
    def setMsgboxWindow(self, win):
        self.win = win

    def getPropertyValue(self, n,v):
        p = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
        p.Name = n
        p.Value = v
        return p

    def msgbox(self, msg='<Hello World>', title='<Dummy>', etyp=MESSAGEBOX,ebtn=BUTTONS_OK):
        mbox = self.tk.createMessageBox(self.win,etyp,ebtn,title,msg)
        return mbox.execute()        
    
    def mri(self, obj):
        mri = self.createUnoService("mytools.Mri")
        mri.inspect(obj)


def DocRedlining(ofc):
    dtp = ofc.StarDesktop
    # Note: in LibreOffice, you must open the revision first, then the source second, to get the correct redlining
    # Open /tmp/revision.docx
    sUrl = uno.systemPathToFileUrl("/tmp/revision.docx")
    oDoc = dtp.loadComponentFromURL(sUrl, "_blank", 0, ())

    oDocFrame = oDoc.CurrentController.Frame
    dispatcher = ofc.createUnoService("com.sun.star.frame.DispatchHelper")

    # Compare it with /tmp/source.docx
    PropVal = ( ofc.getPropertyValue("URL","file:///tmp/source.docx"), )
    dispatcher.executeDispatch(oDocFrame, ".uno:CompareDocuments", "", 0, PropVal)

    # Show the track changes
    args1 = ( ofc.getPropertyValue("ShowTrackedChanges",True), )
    dispatcher.executeDispatch(oDocFrame, ".uno:ShowTrackedChanges", "", 0, args1)

    # Dismiss the track changes box
    args2 = (ofc.getPropertyValue("AcceptTrackedChanges", False),)
    dispatcher.executeDispatch(oDocFrame, ".uno:AcceptTrackedChanges", "", 0, args2)

    # Save the file to /tmp/redlined.pdf
    args3 = (
        ofc.getPropertyValue("URL", "file:///tmp/redlined.pdf"),
        ofc.getPropertyValue("FilterName", "writer_pdf_Export"),
        ofc.getPropertyValue(
            "FilterData", (
                ("UseLosslessCompression", 0, False, DIRECT_VALUE), 
                ("Quality", 0, 90, DIRECT_VALUE),
                ("ReduceImageResolution", 0, True, DIRECT_VALUE),
                ("MaxImageResolution", 0, 300, DIRECT_VALUE),
                ("UseTaggedPDF", 0, False, DIRECT_VALUE), 
                ("SelectPdfVersion", 0, 0, DIRECT_VALUE),
                ("ExportNotes", 0, False, DIRECT_VALUE),
                ("ViewPDFAfterExport", 0, False, DIRECT_VALUE),
                ("ExportBookmarks",0, True, DIRECT_VALUE),
                ("OpenBookmarkLevels", 0, -1, DIRECT_VALUE),
                ("UseTransitionEffects", 0, True, DIRECT_VALUE),
                ("IsSkipEmptyPages", 0, True, DIRECT_VALUE),
                ("ExportPlaceholders",0, True, DIRECT_VALUE),
                ("IsAddStream",0, False, DIRECT_VALUE),
                ("FormsType", 0, 0, DIRECT_VALUE),
                ("ExportFormFields", 0, True, DIRECT_VALUE),
                ("AllowDuplicateFieldNames", 0, False, DIRECT_VALUE),
                ("HideViewerToolbar", 0, False, DIRECT_VALUE),
                ("HideViewerMenubar", 0, False, DIRECT_VALUE),
                ("HideViewerWindowControls", 0, False, DIRECT_VALUE),
                ("ResizeWindowToInitialPage", 0, False, DIRECT_VALUE),
                ("CenterWindow", 0, False, DIRECT_VALUE),
                ("OpenInFullScreenMode", 0, False, DIRECT_VALUE),
                ("DisplayPDFDocumentTitle", 0, True, DIRECT_VALUE),
                ("InitialView", 0, 0, DIRECT_VALUE), 
                ("Magnification", 0, 0, DIRECT_VALUE),
                ("Zoom", 0, 100, DIRECT_VALUE),
                ("PageLayout", 0, 0, DIRECT_VALUE),
                ("FirstPageOnLeft", 0, False, DIRECT_VALUE), 
                ("InitialPage", 0, 1, DIRECT_VALUE),
                ("Printing", 0, 2, DIRECT_VALUE),
                ("Changes", 0, 4, DIRECT_VALUE),
                ("EnableCopyingOfContent", 0, True,DIRECT_VALUE),
                ("EnableTextAccessForAccessibilityTools", 0, True, DIRECT_VALUE), 
                ("ExportLinksRelativeFsys", 0, False, DIRECT_VALUE), 
                ("PDFViewSelection", 0, 0, DIRECT_VALUE), 
                ("ConvertOOoTargetToPDFTarget", 0, False, DIRECT_VALUE), 
                ("ExportBookmarksToPDFDestination", 0, False, DIRECT_VALUE), 
                ("SignPDF", 0, False, DIRECT_VALUE), 
            )
        )
    )
    dispatcher.executeDispatch(oDocFrame, ".uno:ExportToPDF", "", 0, args3)

    # Save the file to /tmp/redlined.docx
    args4 = (
        ofc.getPropertyValue("URL", "file:///tmp/redlined.docx"),
        ofc.getPropertyValue("FilterName", "MS Word 2007 XML")
    )
    dispatcher.executeDispatch(oDocFrame, ".uno:SaveAs", "", 0, args4)

    # Close the window
    oDocFrame.close(False)


ofc = Office(uno.getComponentContext(), "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
DocRedlining(ofc)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
tiendatanduin
Posts: 9
Joined: Fri Dec 15, 2017 1:47 pm

Re: Execute macro in command line returns nothing

Post by tiendatanduin »

You're awesome, Villeroy! We have a plan to turn LibreOffice into a listening mode and convert a few of our commands (e.g. convert to pdf, in-development redlining) to Python or Java, but haven't done it yet due to lacking of development resources. What you did here will save us a ton of investigation time :) And I might pursue this approach in a near future.

For those who are curious about my progress, I think I have found a kind of hack-y way to keep going with the original direction, which is editing the Module1.vba directly to insert the macro directly into LibreOffice from command line. Basically, you just have to paste this following content into the file <LibreOffice_install_dir>/user/basic/Standard/Module1.vba, and the macro will be available instantly in LibreOffice. But again, Villeroy's approach is much more scalable.

Code: Select all

<?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">
sub DocRedlining(revisionPath, sourcePath, redlinedPath)

dim sUrl as string
dim oDoc as object, oDocFrame as object, dispatcher as object

rem Load the revision file in hidden mode so that there&apos;s no UI shown
dim PropVal1(0) as new com.sun.star.beans.PropertyValue
PropVal1(0).Name = "Hidden"
PropVal1(0).Value = true
sUrl = convertToUrl(revisionPath)
oDoc = stardesktop.LoadComponentFromURL(sUrl, "_blank", 0, PropVal1())

oDocFrame = oDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem Load the source file to compare against the revision. Note: you must load the revision first, then the source.
dim PropVal2(0) as new com.sun.star.beans.PropertyValue
PropVal2(0).Name = "URL"
PropVal2(0).Value = convertToUrl(sourcePath)
dispatcher.executeDispatch(oDocFrame, ".uno:CompareDocuments", "", 0, PropVal2())

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ShowTrackedChanges"
args1(0).Value = true
dispatcher.executeDispatch(oDocFrame, ".uno:ShowTrackedChanges", "", 0, args1())

dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "AcceptTrackedChanges"
args2(0).Value = false
dispatcher.executeDispatch(oDocFrame, ".uno:AcceptTrackedChanges", "", 0, args2())

rem Export the redlined to a pdf
dim args3(2) as new com.sun.star.beans.PropertyValue
args3(0).Name = "URL"
args3(0).Value = convertToUrl(redlinedPath)
args3(1).Name = "FilterName"
args3(1).Value = "writer_pdf_Export"
args3(2).Name = "FilterData"
args3(2).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ViewPDFAfterExport",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarks",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportPlaceholders",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportFormFields",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Magnification",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageLayout",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportLinksRelativeFsys",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Watermark",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPasswords",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPermissionPassword",0,Array(),com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureLocation",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureReason",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureContactInfo",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignaturePassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureCertificate",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureTSA",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE))
dispatcher.executeDispatch(oDocFrame, ".uno:ExportToPDF", "", 0, args3())

rem Close the frame
oDocFrame.Close(False)

end sub
</script:module>
LibreOffice 5.2.3.3 and Mac OS X El Capitan
Post Reply