1

我正在尝试使用 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

两者都没有错误,但页面仍然是纵向的..有人有想法吗?

提前致谢!!

4

1 回答 1

0

try : oObj2.setPropertyValue("IsLandscape",True) see http://codesnippets.services.openoffice.org/Calc/Calc.SwitchOrientation.snip

于 2013-09-17T21:11:29.097 回答