ふと出来ないかなぁと思って調べてみたら、OpenOffice.orgを使えば以外に簡単にできるらしい。
まず、こんな感じに通信ソケットを開くようにOpenOffice.orgを起動しておく。
soffice "-accept=socket,host=localhost,port=2002;urp;"
その後、Pythonで外部コントロール
import uno
import unohelper
from com.sun.star.beans import PropertyValue
localContext = uno.getComponentContext()
# connect to the running ooo
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext)
ctx = resolver.resolve(
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
smgr= ctx.ServiceManager
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
filepath = "/home/makoto/test.ppt"
ppt = desktop.loadComponentFromURL(
unohelper.systemPathToFileUrl(filepath),
"_blank",
0,
(),)
args = []
args1 = PropertyValue()
args1.Name = "FilterName"
args1.Value = "impress_pdf_Export"
args2 = PropertyValue()
args2.Name = "Pages"
args2.Value = "All";
args.append(args1)
args.append(args2)
url = "file:///home/makoto/test.pdf"
ppt.storeToURL(url, tuple(args))
ppt.close(True)
案外簡単