openoffice转pdf报错

取名字最烦了 发布于 2016/05/10 15:24
阅读 642
收藏 0

就是偶尔有一两个world转换出问题;求高手指点下

代码如下:

public class KMDocConverter {


private final static Logger logger = Logger.getLogger(KMDocConverter.class);
public void docToPdf(File docFile, File pdfFile){ 
OpenOfficeConnection connection = new SocketOpenOfficeConnection("192.168.40.47",6600);  
         try {  
             connection.connect();  
             DocumentConverter converter = new OpenOfficeDocumentConverter(connection);  
converter.convert(docFile , pdfFile );  
             // close the connection  
             connection.disconnect();  
             System.out.println("****pdf转换成功,PDF输出:" + pdfFile.getPath()+ "****");  
         } catch (java.net.ConnectException e) {  
             e.printStackTrace();  
             System.out.println("****openoffice服务未启动!****");  
             logger.error(e, e);
         } catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {  
             e.printStackTrace();  
             System.out.println("****读取转换文件失败****");  
             logger.error(e, e);
         } catch (Exception e) {  
             e.printStackTrace();  
             logger.error(e, e);
         }  
}
public static void main(String[] args) {
String docFilePath = "C:\\work\\ADMS-SD.docx";
String pdfFilePath = "C:\\work\\ADMS-SD.pdf";
File docFile = new File(docFilePath);
File pdfFile = new File(pdfFilePath);

KMDocConverter converter = new KMDocConverter();
converter.docToPdf(docFile, pdfFile);

}

}
报错信息如下:

java.lang.IllegalArgumentException: inputFile doesn't exist: C:\work\ADMS-SD.docx

at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:90)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:74)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:70)
at com.plug.knowledge.KMDocConverter.docToPdf(KMDocConverter.java:119)
at com.plug.knowledge.KMDocConverter.main(KMDocConverter.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.launching.LongCommandLineLauncher.main(LongCommandLineLauncher.java:43)
加载中
返回顶部
顶部