How can i get the page margin using java api?

Java, C++, C#, Delphi, ??? - Using the UNO bridges

How can i get the page margin using java api?

Postby conghaoyuan » Fri Jun 03, 2016 11:44 am

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

Code: Select all   Expand viewCollapse view
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
conghaoyuan
 
Posts: 1
Joined: Fri Jun 03, 2016 11:40 am

Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest