- 浏览: 222603 次
- 性别:
文章分类
最新评论
-
hzy20113751:
请问一下码友:DocumentConverter conver ...
Java跨平台将word转为pdf(结合Jodconverter 和OpenOffice.org) -
哇哈哈1:
楼主 你好 看了你的文章顿时收益颇深 可以提问吗?htm ...
Java HTML直接导出PDF -
xlshl43:
首先,第一种、第二种方法基本一样。第三种方法我正在用,大伙下不 ...
Java跨平台将word转为pdf(结合Jodconverter 和OpenOffice.org) -
大海你好:
错误:“Stream closed”楼主,没找到哪里有哦错
Java HTML直接导出PDF -
微站题:
能给我发下jar包吗,有3个没有下载到 297196894@q ...
Java HTML直接导出PDF
Java跨平台将word转为pdf
(结合Jodconverter开源框架 和OpenOffice.org办公软件)
Jodconverter的版本:jodconverter 2.2.1
maven:
<dependency> <groupId>com.artofsolving</groupId> <artifactId>jodconverter</artifactId> <version>2.2.1</version> </dependency>
网上的流传的方法:
1. 安装OpenOffice 3 下载路径:http://zh.openoffice.org/new/zh_cn/downloads.html
2. 启动OpenOffice服务
cd C:\Program Files\OpenOffice.org 3\program
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
3. 利用Jodconverter编写转换类
public void convert(String input, String output){ File inputFile = new File(input); File outputFile = new File(output); OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100); try { connection.connect(); DocumentConverter converter = new OpenOfficeDocumentConverter(connection); converter.convert(inputFile, outputFile); } catch(Exception e) { e.printStackTrace(); } finally { try{ if(connection != null){connection.disconnect(); connection = null;}}catch(Exception e){} } }
以上方法需要启动OpenOffice的服务,麻烦且占内存。
后来,有人又整理了一个方法:直接在转换类中调用启动服务。
public static int office2PDF(String sourceFile, String destFile) { String OpenOffice_HOME = "D:/Program Files/OpenOffice.org 3";// 这里是OpenOffice的安装目录, // 在我的项目中,为了便于拓展接口,没有直接写成这个样子,但是这样是尽对没题目的 // 假如从文件中读取的URL地址最后一个字符不是 '\',则添加'\' if (OpenOffice_HOME.charAt(OpenOffice_HOME.length() - 1) != '/') { OpenOffice_HOME += "/"; } Process pro = null; try { // 启动OpenOffice的服务 String command = OpenOffice_HOME + "program/soffice.exe -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\""; pro = Runtime.getRuntime().exec(command); // connect to an OpenOffice.org instance running on port 8100 OpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100); connection.connect(); // convert DocumentConverter converter = new OpenOfficeDocumentConverter(connection); converter.convert(inputFile, outputFile); // close the connection connection.disconnect(); // 封闭OpenOffice服务的进程 pro.destroy(); return 0; } catch (FileNotFoundException e) { e.printStackTrace(); return -1; } catch (IOException e) { e.printStackTrace(); } finally { pro.destroy(); } return 1; }
本人却在google code无意中发现jodconverter 的新版本jodconverter-core 3.0-beta-4。
但是不知道为什么用不了maven,只能下载包 。地址:https://code.google.com/p/jodconverter/downloads/list
并结合其他开发者的整理如下:
/** * 将Office文档转换为PDF. 运行该函数需要用到OpenOffice, OpenOffice * * @param sourceFile * 源文件,绝对路径. 可以是Office2003-2007全部格式的文档, Office2010的没测试. 包括.doc, .docx, .xls, .xlsx, .ppt, .pptx等. * * @param destFile * 目标文件.绝对路径. */ public static void word2pdf(String inputFilePath) { DefaultOfficeManagerConfiguration config = new DefaultOfficeManagerConfiguration(); String officeHome = getOfficeHome(); config.setOfficeHome(officeHome); OfficeManager officeManager = config.buildOfficeManager(); officeManager.start(); OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager); String outputFilePath = getOutputFilePath(inputFilePath); File inputFile = new File(inputFilePath); if (inputFile.exists()) {// 找不到源文件, 则返回 File outputFile = new File(outputFilePath); if (!outputFile.getParentFile().exists()) { // 假如目标路径不存在, 则新建该路径 outputFile.getParentFile().mkdirs(); } converter.convert(inputFile, outputFile); } officeManager.stop(); } public static String getOutputFilePath(String inputFilePath) { String outputFilePath = inputFilePath.replaceAll(".doc", ".pdf"); return outputFilePath; } public static String getOfficeHome() { String osName = System.getProperty("os.name"); if (Pattern.matches("Linux.*", osName)) { return "/opt/openoffice.org3"; } else if (Pattern.matches("Windows.*", osName)) { return "D:/Program Files/OpenOffice.org 3"; } else if (Pattern.matches("Mac.*", osName)) { return "/Application/OpenOffice.org.app/Contents"; } return null; }
- jodconverter-core-3.0-beta-4-sources.jar (51.9 KB)
- 下载次数: 703
- jodconverter-core-3.0-beta-4.jar (68.2 KB)
- 下载次数: 1122
评论
14 楼
hzy20113751
2018-09-06
请问一下码友:
DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
converter.convert(SourceFile, PdfFile);//连接的时候很慢.这该如何优化呢?
DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
converter.convert(SourceFile, PdfFile);//连接的时候很慢.这该如何优化呢?
13 楼
xlshl43
2016-10-09
首先,第一种、第二种方法基本一样。第三种方法我正在用,大伙下不到包,可以在github中找,支持maven。
但是优劣讲下:
先说第三种,优点:只需要安装openOffice,然后java代码启动,对运维人员基本透明。
缺点:如果有多个应用想用OpenOffice,启动两次会报错,只能装两个OpenOffice,这样更耗资源
第一、二种,优点:只需安装一个openoffice,并且只需启动一次,多个应用可同时使用,符合基本要求
缺点:暂时不知道
至于作者的观点中,第一二种方法麻烦且占内存,不知从何而来?数据库不就是这么用的?如果嫌链接每次建立释放麻烦,可以用连接池啊,嫌连接池麻烦,可以自己写一个简单的连接复用呀,所以,我找不到第一、二种的缺点,我们项目目前已从第三种换为了第一种方式,最正常,最符合逻辑的一种方式!
但是优劣讲下:
先说第三种,优点:只需要安装openOffice,然后java代码启动,对运维人员基本透明。
缺点:如果有多个应用想用OpenOffice,启动两次会报错,只能装两个OpenOffice,这样更耗资源
第一、二种,优点:只需安装一个openoffice,并且只需启动一次,多个应用可同时使用,符合基本要求
缺点:暂时不知道
至于作者的观点中,第一二种方法麻烦且占内存,不知从何而来?数据库不就是这么用的?如果嫌链接每次建立释放麻烦,可以用连接池啊,嫌连接池麻烦,可以自己写一个简单的连接复用呀,所以,我找不到第一、二种的缺点,我们项目目前已从第三种换为了第一种方式,最正常,最符合逻辑的一种方式!
12 楼
tesia
2015-12-15
jodconverter-core 3.0-beta-4 Maven用不了 是因为库里面只有2.2.1版本的jodconverter
http://search.maven.org/#search%7Cga%7C1%7Cjodconverter3
http://search.maven.org/#search%7Cga%7C1%7Cjodconverter3
11 楼
hwxiait
2015-11-08
https://www.showapi.com/api/lookPoint/770
10 楼
qcxiaofan
2015-05-28
大哥 我Word转pdf的时候 2003版的不能转报错,2007版本的就没问题 能稍微指点下么 我都急死了,求QQ 或者群之类的联系方式 。浏览器上报错:"offsetParent is not set -- cannot scroll" viewer.js:150:4
scrollIntoView() viewer.js:150
PDFViewer_scrollPageIntoView() viewer.js:4325
pagechange() viewer.js:6909
PDFViewer.prototype.currentPageNumber() viewer.js:4012
pdfViewSetInitialView() viewer.js:6178
resolved()
后台报错:com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed
at com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter.convertInternal(StreamOpenOfficeDocumentConverter.java:95)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:82)
at com.jfok.server.service.AttachmentService.uploadnewFile(AttachmentService.java:164)
at com.jfok.server.service.AttachmentService$$FastClassByCGLIB$$e3537a77.invoke(<generated>)
scrollIntoView() viewer.js:150
PDFViewer_scrollPageIntoView() viewer.js:4325
pagechange() viewer.js:6909
PDFViewer.prototype.currentPageNumber() viewer.js:4012
pdfViewSetInitialView() viewer.js:6178
resolved()
后台报错:com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed
at com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter.convertInternal(StreamOpenOfficeDocumentConverter.java:95)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:82)
at com.jfok.server.service.AttachmentService.uploadnewFile(AttachmentService.java:164)
at com.jfok.server.service.AttachmentService$$FastClassByCGLIB$$e3537a77.invoke(<generated>)
9 楼
ljlleo
2014-09-10
你好:我使用的第三种方式,在linux环境下,为什么一直是启动服务失败呢?异常如下:
org.artofsolving.jodconverter.office.OfficeException: failed to start and connect
java.lang.IllegalStateException: this OfficeManager is currently stopped
at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.execute(ProcessPoolOfficeManager.java:70)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:78)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:69)
at com.diandiyun.common.utils.OpenOfficePDFConverter.convert2PDF(OpenOfficePDFConverter.java:23)
at com.diandiyun.common.utils.FileUtils.docToPdf(FileUtils.java:635)
at com.diandiyun.eduplat.project.web.CourseController.upload(CourseController.java:256)
at com.diandiyun.eduplat.project.web.CourseController$$FastClassByCGLIB$$dc4f7acf.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.artofsolving.jodconverter.office.OfficeException: failed to start and connect
java.lang.IllegalStateException: this OfficeManager is currently stopped
at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.execute(ProcessPoolOfficeManager.java:70)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:78)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:69)
at com.diandiyun.common.utils.OpenOfficePDFConverter.convert2PDF(OpenOfficePDFConverter.java:23)
at com.diandiyun.common.utils.FileUtils.docToPdf(FileUtils.java:635)
at com.diandiyun.eduplat.project.web.CourseController.upload(CourseController.java:256)
at com.diandiyun.eduplat.project.web.CourseController$$FastClassByCGLIB$$dc4f7acf.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
8 楼
myparadise89
2014-07-29
你好,我用的是第一种方法,程序编译无错误,运行时显示如下错误Exception in thread "main" java.lang.IllegalStateException: invalid officeHome: it doesn't contain soffice.bin: D:\Program Files (x86)\OpenOffice.org 3,D:\Program Files (x86)\OpenOffice.org 3为Office2PDF安装路径。请问为什么会出错,谢谢
7 楼
yhdamon
2014-07-23
与6楼遇到一样的问题,求解决办法
6 楼
ljlleo
2014-07-22
我使用的第三种方式,在linux环境下,为什么一直是启动服务失败呢?异常如下:
org.artofsolving.jodconverter.office.OfficeException: failed to start and connect
java.lang.IllegalStateException: this OfficeManager is currently stopped
at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.execute(ProcessPoolOfficeManager.java:70)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:78)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:69)
at com.diandiyun.common.utils.OpenOfficePDFConverter.convert2PDF(OpenOfficePDFConverter.java:23)
at com.diandiyun.common.utils.FileUtils.docToPdf(FileUtils.java:635)
at com.diandiyun.eduplat.project.web.CourseController.upload(CourseController.java:256)
at com.diandiyun.eduplat.project.web.CourseController$$FastClassByCGLIB$$dc4f7acf.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor$1.proceed(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:82)
at org.apache.shiro.authz.aop.AuthorizingMethodInterceptor.invoke(AuthorizingMethodInterceptor.java:39)
at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor.invoke(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:115)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at com.diandiyun.eduplat.project.web.CourseController$$EnhancerByCGLIB$$dd71ee3e.upload(<generated>)
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.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:149)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
org.artofsolving.jodconverter.office.OfficeException: failed to start and connect
java.lang.IllegalStateException: this OfficeManager is currently stopped
at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.execute(ProcessPoolOfficeManager.java:70)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:78)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:69)
at com.diandiyun.common.utils.OpenOfficePDFConverter.convert2PDF(OpenOfficePDFConverter.java:23)
at com.diandiyun.common.utils.FileUtils.docToPdf(FileUtils.java:635)
at com.diandiyun.eduplat.project.web.CourseController.upload(CourseController.java:256)
at com.diandiyun.eduplat.project.web.CourseController$$FastClassByCGLIB$$dc4f7acf.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor$1.proceed(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:82)
at org.apache.shiro.authz.aop.AuthorizingMethodInterceptor.invoke(AuthorizingMethodInterceptor.java:39)
at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor.invoke(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:115)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at com.diandiyun.eduplat.project.web.CourseController$$EnhancerByCGLIB$$dd71ee3e.upload(<generated>)
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.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:149)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
5 楼
sun123start
2013-10-30
你好,我使用你说的第三种方式jodconverter-core 3.0-beta-4。但是出现这种错误,invalid officeHome: it doesn't contain soffice.bin: C:\Program Files (x86)\OpenOffice 4\program 不知道你有没有遇过,我想是不是我装的openoffice3.4有问题?
4 楼
leipan19890705
2013-07-24
你好!请问你用OpenOffice将word等转换为pdf,会失真吗?我转的一些word文档里面有一些图表、公式,转出来就都成了空白的。你知道是什么原因吗?
3 楼
albertshaw
2013-07-22
方法二命令带空格了
改成数组才能执行
connection要申明在try block外面,然后在finally关闭。
String command = OpenOffice_HOME + "program/soffice.exe -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\"";
改成数组才能执行
String[] command = {OpenOffice_HOME+"program\\soffice.exe","-headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard"};
connection要申明在try block外面,然后在finally关闭。
2 楼
huangronaldo
2012-12-31
java-xb 写道
你好,我也是使用你说的第三种方式jodconverter-core 3.0-beta-4。 进行转码
发现 我必须在window下面启动一下 soffice服务 , 然后 OfficeManager才能建立连接 ,当调用officeManager.stop()时 他会关闭 我启动的soffice服务 ,关闭之后 我重新运行上面的例子就报 failed to start and connect异常。你是不是遇到过呢
发现 我必须在window下面启动一下 soffice服务 , 然后 OfficeManager才能建立连接 ,当调用officeManager.stop()时 他会关闭 我启动的soffice服务 ,关闭之后 我重新运行上面的例子就报 failed to start and connect异常。你是不是遇到过呢
return "D:/Program Files/OpenOffice.org 3"; 你的OpenOffice是不是装在这里,如果不是的话,得修改这里!
1 楼
java-xb
2012-12-12
你好,我也是使用你说的第三种方式jodconverter-core 3.0-beta-4。 进行转码
发现 我必须在window下面启动一下 soffice服务 , 然后 OfficeManager才能建立连接 ,当调用officeManager.stop()时 他会关闭 我启动的soffice服务 ,关闭之后 我重新运行上面的例子就报 failed to start and connect异常。你是不是遇到过呢
发现 我必须在window下面启动一下 soffice服务 , 然后 OfficeManager才能建立连接 ,当调用officeManager.stop()时 他会关闭 我启动的soffice服务 ,关闭之后 我重新运行上面的例子就报 failed to start and connect异常。你是不是遇到过呢
发表评论
-
JSTL的XML处理标签库
2012-06-18 11:14 2537JSTL的XML处理标签 ... -
PDFUtils常用方法
2012-06-15 09:39 1289自个整理的一个生成PDF的常用方法: package ... -
用css来控制打印的pdf样式
2012-06-15 09:36 2750@page { size: A4 landscape ... -
Java HTML直接导出PDF
2012-06-09 09:12 58421Java HTML直接导出PDF 对于java中如何从h ... -
List Map分组应用的小例子
2012-03-28 12:22 4682package com.common.main.mapA ... -
Java 实现遍历节点方法
2012-03-23 10:22 1494此方法有用于动态表头制作,多级菜单的制作。 首先在数据 ... -
润乾报表的参数
2012-03-19 09:38 4843◆缺省参数输入页面—1.1.2.a.jsp 为了方便 ... -
Eclipse中最常用的快捷键
2011-11-15 10:06 716根据在项目中的实践,现总结如下,给自己以后的项目加 ...
相关推荐
`JodConverter`是一个基于OpenOffice的开源Java库,它允许开发者通过API将Microsoft Office文档(如DOC、XLS、PPT)转换为OpenDocument格式(ODT、ODS、ODP)或者PDF。`JodConverter`利用了OpenOffice的内部转换功能...
jodconverter-2.2.2.zip 利用openoffice word转pdf所需jar 使用说明:https://blog.csdn.net/weixin_40845192/article/details/104660387
JodConverter一个Java的OpenDocument 文件转换器,可以进行...本资源包含了所有的jodconverter及相关jar包以及java代码和openoffice服务器文档,供大家下载使用。 OpenOffice的下载地址:http://www.openoffice.org/
Java跨平台将word转为pdf(结合Jodconverter 和OpenOffice.org)
jodconverter的核心是OpenOffice.org或LibreOffice的自动化接口,它利用这些办公套件的转换能力,将Word文档转换成PDF。由于OpenOffice和LibreOffice支持多种文件格式,因此jodconverter实际上也支持其他格式的转换...
3. **跨平台兼容**:由于JodConverter是基于Java的,所以它可以运行在任何支持Java的平台上,包括Windows、Linux和Mac OS。 **最佳实践** 使用JodConverter时,应遵循以下最佳实践: 1. **优化性能**:为了提高...
linux和windows安装openOffice java通过jodconverter 将excel、doc文件转成pdf或html,比2.2.1版本相比 提供office 2007版本支持 maven是只有2.2.1版本的maven依赖; maven 安装jar包到本地命令 mvn install:install-...
JodConverter是一款开源的Java库,它利用OpenOffice或LibreOffice的能力,能够将Microsoft Office文档(如.doc、.xls、.ppt)转换为OpenDocument格式或者PDF。尽管在Maven仓库中可找到的最新版本是2.2.1,但针对2007...
这个例子展示了如何利用Java和OpenOffice将Word文档转换为PDF,这对于自动化文档处理、批量转换或集成到企业系统中都非常有用。在实际应用中,你可能需要根据具体需求对代码进行调整,比如处理多个文件、配置转换...
JodConverter 是一个流行的开源Java库,用于将OpenOffice或LibreOffice文档转换为其他格式,如PDF、DOCX到PDF等。这个资源包提供了JodConverter的2.2.2版本,对于那些在Maven自动下载过程中遇到困难的开发者来说,这...
在IT领域,文档转换是一项常见的任务,而JODConverter作为一款开源的Java库,广泛用于自动化转换各种文档格式,如.doc、.pdf、.odt等。然而,在实际应用中,正确配置并连接到OpenOffice服务可能会遇到一些挑战。本文...
openoffice 软件用到的 jodconverter-2.2.2.jar 资源 (07 格式需要的222版本) 不想耗费积分的可以从官网下载, 地址如下: 官网https://sourceforge.net/projects/jodconverter/files/ maven的配置如下: <groupId>...
JODConverter是基于OpenOffice.org的一个开源项目,它提供了强大的文档转换功能,能够将Microsoft Office格式的文档(如.doc、.xls、.ppt)转换为OpenDocument格式(如.odt、.ods、.odp),反之亦然。这个工具的灵活...
jodconverter-2.2.2.jar支持使用java转docx、pptx等为html\pdf。 该包依赖commons-io-2.0.1 ,commons-lang3-3.4、javassist-3.11.0.GA。这几个包maven中央仓库有
import org.artofsolving.jodconverter.OfficeDocumentConverter; import org.artofsolving.jodconverter.office.OfficeManager; // 初始化OfficeManager,连接到OpenOffice或LibreOffice OfficeManager office...
Java使用OpenOffice转换Office文档为PDF是一种常见的技术需求,尤其在企业级应用中,为了保持一致性和跨平台兼容性,可能会需要将Word、Excel或PowerPoint文档转换为PDF格式。以下将详细介绍如何在Java环境中利用...
由于OpenOffice内部支持多种文档格式的互转,JODConverter通过与OpenOffice的交互,实现了跨平台的文档转换功能,包括docx到其他格式的转换。 要使用JODConverter 2.2.2,首先需要在项目中引入对应的jar包。在提供...