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

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?

Hi

For example with LibreOffice Basic:

Sub Main

dim sUrl as string
dim oDoc as object
dim props(0) As New com.sun.star.beans.PropertyValue

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
	oDoc.close(True)
	On Error GoTo 0

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

End Sub

Regards

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?