Hi,
What would be the minimalist python script to save an odt file as txt file?
Below an example script, that opens one odt file saves it as another
odt file.
However I do not know how to convert it (to apply an output filter)
def convert_file(fname_in,fname_out):
local = uno.getComponentContext()
resolver = local.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", local)
context = resolver.resolve(
"uno:socket,host=localhost,"
+"port=2002;urp;StarOffice.ComponentContext"
)
desktop = context.ServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", context)
# open input file
url_in = unohelper.systemPathToFileUrl( os.path.abspath(fname_in))
doc = desktop.loadComponentFromURL( url_in, "_blank", 0, () )
# save file
url_out = unohelper.systemPathToFileUrl( os.path.abspath(fname_out))
# next command saves, but without converting to txt format.
doc.storeToURL(url_out, ())
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]