How can i get the page margin using java api?

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
conghaoyuan
Posts: 1
Joined: Fri Jun 03, 2016 11:40 am

How can i get the page margin using java api?

Post by conghaoyuan »

i did some works ,but it'a wrong, and i consulted the official docs , no answers

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;
    }
openoffice 4.12 windows 64bit
Post Reply