zippy1978 / ghost4j

Java wrapper for Ghostscript C API + PS/PDF document handling API
http://www.ghost4j.org
GNU Lesser General Public License v3.0
64 stars 38 forks source link

ERROR: invalid officeHome: it doesn't contain soffice.bin: #38

Closed dondell closed 8 years ago

dondell commented 9 years ago

Hi dev,

This is my first time in using this and i got an error. Below is the code.

public class Do_converter {

static String officePath ="D:\\Projects\\BWServer\\BWServer\\src\\powerpoint_recieved\\";

static String testDoc = "D:\\Projects\\BWServer\\BWServer\\src\\powerpoint_recieved\\converted.pdf";
public static void main( String[] args )
{

    OfficeManager officeManager = null;

    File sourceFile =new File(testDoc);
    File pdfFile =new File(testDoc + ".pdf");

    /** Step 1 : Convert Document into pdf **/
    try{
        officeManager = new DefaultOfficeManagerConfiguration()
                        .setOfficeHome(officePath)
                        .buildOfficeManager();

        officeManager.start();

        OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
        converter.convert(sourceFile, pdfFile);
    }catch(Exception ex){
        System.out.println("ERROR: " + ex.getMessage());
        return;
    }finally {
        if(officeManager!=null)
            officeManager.stop();
    }

    /** Step 2: Convert PDF into image sequence **/
    try{
        // load PDF document
        PDFDocument document = new PDFDocument();
        document.load(pdfFile);

        // create renderer
        SimpleRenderer renderer = new SimpleRenderer();

        // set resolution (in DPI)
        renderer.setResolution(300);

        // render
        List<Image> images = renderer.render(document);

        // write images to files to disk as PNG
        try {
            for (int i = 0; i < images.size(); i++) {
                ImageIO.write((RenderedImage) images.get(i), "png", new File(officePath+(i + 1) + ".png"));
            }
        } catch (IOException ex) {
            System.out.println("ERROR: " + ex.getMessage());
        }
    }catch (Exception ex){
        System.out.println("ERROR: " + ex.getMessage());
    }
}

}

zippy1978 commented 9 years ago

Hi,

The OfficeDocumentConverter is not part of Ghost4J... Where did you find it ? I think your issue is lore related to this converter than to Ghost4J itself...

Regards, Gilles