2016-08-25 3 views

Répondre

0

1er besoin de définir la variable de chemin de Open Office, puis cmd ouvert avec bureau ouvert installé l'emplacement puis exécutez une commande

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

Utilisez ce code dans votre projet 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(); 
       }