我正在尝试使用 python 在 OpenOffice 文档中设置页面方向。我用来尝试以下代码:
import json
from win32com.client import Dispatch as Dispatch
svm = Dispatch("com.sun.star.ServiceManager")
svm._FlagAsMethod("Bridge_GetStruct")
coreflect = svm.createInstance("com.sun.star.reflection.CoreReflection")
desktop = svm.createInstance("com.sun.star.frame.Desktop")
doc = desktop.loadComponentFromURL("private:factory/swriter", "_blank",0, [])
txt = doc.getText()
cur = txt.createTextCursor()
然后我尝试了两种不同的方法:
p = doc.getPagePrintSettings()
p[8].Value = True
doc.setPagePrintSettings(p)
和
oStyleFamilies = doc.getStyleFamilies()
oObj1 = oStyleFamilies.getByName("PageStyles")
oObj2 = oObj1.getByName("Default")
oObj2.IsLandscape = True
两者都没有错误,但页面仍然是纵向的..有人有想法吗?
提前致谢!!