Search code examples
build-processbuild-automationnantopenoffice.orglibreoffice

OpenOffice command line PDF creation


I have some documentation written in OpenOffice, and I would like to include some of it as PDF files in the final build deliveries. I would like to do this with the automated build script.

Is there a way to create a PDF file from OpenOffice with a command line command?


Solution

  • Art of Solving has also a very good API to perform the conversion in Java. It is a little slow but it is simple enough. This is how I use it:

            File inputFile = new File("C:\\oreyes\\hola.doc"); 
            File outputFile = new File("C:\\oreyes\\hola.pdf"); 
            OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
            try { 
                connection.connect(); 
            } catch(Exception e) {}
    
            DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
            converter.convert(inputFile, outputFile); 
            connection.disconnect(); 
    

    You can create a jar with that and process it from the command line.