2016-08-25 44 views

回答

0

1日需要設置開放式辦公的路徑變量,然後打開CMD用開放式辦公室安裝位置,然後運行命令

soffice -headless -accept="socket,host=localhost,port=8100;urp;" -nofirststartwizard 

使用此代碼Java項目:

OpenOfficeConnection connection = new SocketOpenOfficeConnection("localhost",8100); 

      try { 
       connection.connect(); 
       long t1 = System.currentTimeMillis(); 
       DocumentConverter converter = new OpenOfficeDocumentConverter(connection); 

       converter.convert(inputFile, outputFileLoacation); 
       long t2 = System.currentTimeMillis(); 
       System.out.println(input + " = " + (t2 - t1) + " ms"); 

      } catch (ConnectException e) { 
       e.printStackTrace(); 
      } finally { 
       if (connection.isConnected()) { 
        connection.disconnect(); 
       }