Code: Select all
public long[] getPageMargin(String fileUrl , String password) throws Exception{
long[] pageMargin = new long[4];
try{
xEmptyWriterComponent = newDocComponent(fileUrl, password);
mxDoc = (XTextDocument) UnoRuntime.queryInterface(
XTextDocument.class, xEmptyWriterComponent);
XPropertySet mxDocProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, mxDoc);
System.out.println(mxDocProps.getPropertyValue("Name"));
//PageStyleLayout pageStyle =
XPagePrintable xPagePrintable = (XPagePrintable)UnoRuntime.queryInterface(XPagePrintable.class, mxDoc);
//PropertyValue[] pagePrint = xPagePrintable.getPagePrintSettings();
// for(int i =0;i<pagePrint.length;i++){
// System.out.println(pagePrint[i].Name+":"+pagePrint[i].Value);
//
// }
//PropertyValue leftMargin = pagePrint[2];
//System.out.println(leftMargin.Value);
}catch(Exception e){
if(logger.isInfoEnabled()){
logger.info("获取页边距:"+e);
}
}finally{
close();
}
return pageMargin;
}