Ask Your Question

Can I automate/script Draw (loading, saving as)?

asked 2016-06-30 15:19:20 +0200

Locutus gravatar image

updated 2016-06-30 15:20:14 +0200

For a coding project I need to "convert" a PDF to Draw's .fodg format.

Right now I do this manually by loading the PDF into Draw and saving it as .fodg. Is there a way to automate/script that, so I can perform the process from another Windows application?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2016-06-30 16:04:13 +0200

pierre-yves samyn gravatar image


For example with LibreOffice Basic:

Sub Main

dim sUrl as string
dim oDoc as object
dim props(0) As New

sUrl = convertToURL("C:\Test\foo.pdf")

If FileExists(sUrl) then
    props(0).Name = "FilterName"
    props(0).Value = "draw_pdf_import"

    oDoc = stardesktop.LoadComponentFromURL(sUrl, "_blank", 0, props())

    props(0).Value = "OpenDocument Drawing Flat XML"

    sUrl = convertToURL("C:\Test\foo.fodg")
    oDoc.storeToURL(sUrl, props())

    on Error Resume Next
    On Error GoTo 0

    msgbox (sUrl & " not found", 16)
End if

End Sub


edit flag offensive delete link more


Many thanks, Pierre!

Is it also possible to launch LO from an external application in a way that this macro gets auto-executed, with the file name passed in as a parameter, and LO closed again afterwards?

Locutus gravatar imageLocutus ( 2016-06-30 16:22:09 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-06-30 15:19:20 +0200

Seen: 60 times

Last updated: Jun 30 '16