文本文档-设置页面大小和页边距

本文关键字:页边距 文档 设置 文本 | 更新日期: 2023-09-27 17:53:46

基于"Hello World"使用OpenOffice 3示例代码,我成功地从c#创建了OpenOffice文本文件。但我仍然找不到设置页面大小和页边距的方法。知道怎么做吗?

谢谢

文本文档-设置页面大小和页边距

我终于找到了,所以如果将来有人需要,代码在这里:

XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)xComponent;
XNameContainer xPageStyleCollection = (XNameContainer)xSupplier.getStyleFamilies().getByName("PageStyles").Value;
XPropertySet xPropertySet = (XPropertySet)xPageStyleCollection.getByName("Default").Value;
xPropertySet.setPropertyValue("LeftMargin", new Any((Int32)(5000))); //mm
xPropertySet.setPropertyValue("RightMargin", new Any((Int32)(9000))); // (1/100)mm
xPropertySet.setPropertyValue("TopMargin", new Any((Int32)(6000))); //(1/100)mm
xPropertySet.setPropertyValue("BottomMargin", new Any((Int32)(7000))); //(1/100)mm
xPropertySet.setPropertyValue("Width", new Any((Int32)(25000))); //(1/100)mm
xPropertySet.setPropertyValue("Height", new Any((Int32)(21000))); //(1/100)mm