0

I want to do some document convert works use jodconverter & open office 4。 I have installed open office on my windows 7 at C:\Program Files (x86)\OpenOffice 4。 in task mgr I have seen the process of soffice.bin*32

when I run my demo to convert a doc file to html file。I occurred this exception:

    log4j:WARN No appenders could be found for logger (org.artofsolving.jodconverter.office.OfficeManager).
log4j:WARN Please initialize the log4j system properly.
一月 07, 2016 10:27:49 上午 org.artofsolving.jodconverter.office.OfficeConnection connect
信息: connected: 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1'
Exception in thread "main" org.artofsolving.jodconverter.office.OfficeException: could not load document: asdf.doc
    at org.artofsolving.jodconverter.AbstractConversionTask.loadDocument(AbstractConversionTask.java:93)
    at org.artofsolving.jodconverter.AbstractConversionTask.execute(AbstractConversionTask.java:53)
    at org.artofsolving.jodconverter.office.ExternalOfficeManager.execute(ExternalOfficeManager.java:70)
    at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:72)
    at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:63)
    at demo.OfficeDocumentManager.conveterOfficeDocument(OfficeDocumentManager.java:84)
    at demo.Test.main(Test.java:9)

I check the source code of jodconverter:

private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
        if (!inputFile.exists()) {
            throw new OfficeException("input document not found");
        }
        XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
        Map<String,?> loadProperties = getLoadProperties(inputFile);
        XComponent document = null;
        try {
            document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
        } catch (IllegalArgumentException illegalArgumentException) {
            throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
        } catch (ErrorCodeIOException errorCodeIOException) {
            throw new OfficeException("could not load document: "  + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
        } catch (IOException ioException) {
            throw new OfficeException("could not load document: "  + inputFile.getName(), ioException);
        }
        if (document == null) {
            throw new OfficeException("could not load document: "  + inputFile.getName());
        }
        return document;
    }

when I debug these code. I find the document always null. the file I want to load here is exist and readable。can anyone told me why I can't load the file??

doctor CUI
  • 11
  • 2
  • 5
  • I find if I change the doc file as docx file,I can load it。so this question is about why open office can not load doc file – doctor CUI Jan 12 '16 at 06:19

1 Answers1

0

I can close this question now,when you come up this question ,you can resave your document,then retry.I think this is because the inner error of the document that make XComponentLoader return null.

doctor CUI
  • 11
  • 2
  • 5