上接 文档展示
http://zhuyufufu.iteye.com/admin/blogs/2009600
本篇实现使用OpenOffice转换文档为PDF功能
上代码:
package com.zas.openoffice.test;
import java.io.File;
import java.net.ConnectException;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
public class OpenOfficeConvertToPDFTest {
/**
* 转换函数
*
* @param sourceFile
* @param destFile
* @return
*/
public static int office2PDF(String sourceFile, String destFile) {
try {
File inputFile = new File(sourceFile);
if (!inputFile.exists()) {
return -1;// 找不到源文件, 则返回-1
}
// 如果目标路径不存在, 则新建该路径
File outputFile = new File(destFile);
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
// 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();
return 0;
} catch (ConnectException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return 1;
}
public static void main(String[] args) {
String filePath = "D:\\pdf\\2010110系统需求分析说明书正式.doc";
String outputFilePath = "D:\\pdf\\ppt\\2010110系统需求分析说明书正式.pdf";
OpenOfficeConvertToPDFTest.office2PDF(filePath, outputFilePath);
}
}
已测试转换PPT Doc 到PDF
当文档超过20M时转换很慢
使用OpenOffice可支持windows linux平台
对于文档展示,从技术上应该只剩下性能调优了。
年后再从功能完善角度实现文档展示功能。
参考文档:
http://www.iteye.com/topic/352103
http://iteye.blog.163.com/blog/static/186308096201211107128117/
分享到:
相关推荐
Word、Excel等常用文档格式通过OpenOffice转换为pdf及图片,亲测,可用。Word、Excel等常用文档格式通过OpenOffice转换为pdf及图片,亲测,可用。Word、Excel等常用文档格式通过OpenOffice转换为pdf及图片,亲测,可用...
openoffice word转pdf excel转pdf ppt转pdf
OpenOffice转换Office文档为PDF、HTML,将word,ppt转成html,Excel转为Html
office文档通过openoffice或者microsoft多线程转换成pdf文档,并通过pdf.js显示
文档在线预览,java使用openoffice转换PDF的工具类及相关jar包。
我从官网下载openoffice4.1.0版的,资源包含有openoffice相关jar包以及java调用文件和部署文档
由于公司项目需要实现类似百度文库在线查看文档的功能,所以自己写了一个小工具,定时读取数据库,将需要转换的文档转换为pdf,再按页转换为swf,并生成第一页的缩略图,在页面使用jquery media插件显示swf,以下是...
java实现附件预览(openoffice+PDF.js),将office文档,通过openoffice工具转换为PDF文件,使用PDF.js进行前端展示 是对openoffice+swftools+flexpaper的升级版,减少一次swf文件转换,及flexpaper只能预览十页内容...
命令行运行ofd xxx.pdf xxx.ofd 有问题联系我qq:466143682 支持转换所有页面,可能有些字体不支持,目前还在测试
可转换doc,docx,ppt,pptx,txt,xls,xlsx,pdf类型的文件格式,转换类自动打开openoffice,在线预览功能,代码齐全。可套用在需要的项目上。
NULL 博文链接:https://titanseason.iteye.com/blog/1471606
使用OpenOffice将文档转换为PDF,将PDF转换为Swf
根据网上的资料总结的一个springboot 转换pdf Word文档大小最好2m以下 需要安装OpenOffice.org 3.3 链接:https://pan.baidu.com/s/1onrkhBCNlGLEmf3hPwzXWw 密码:8h5a
JodConverter一个Java的OpenDocument 文件转换器,可以进行...本资源包含了所有的jodconverter及相关jar包以及java代码和openoffice服务器文档,供大家下载使用。 OpenOffice的下载地址:http://www.openoffice.org/
1.安装OpenOffice软件,此软件功能为将其他类型文件转换为PDF格式。 软件安装没什么可说的,全部下一步就可以了,安装完成后,后台使用JODConverter对软件进行操作。 首先引用JODConverter相关jar包进项目,然后就...
openoffice转pdf所需jodconverter-2.2.2,2,2,1版本不支持xlsx、docx、pptx格式的文档转换pdt。
本篇文章主要介绍了java使用openoffice将office系列文档转换为PDF的示例方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
Word processor formats: Microsoft Word docx, OpenOffice/LibreOffice ODT, OpenDocument XML Ebooks: EPUB Documentation formats: DocBook, GNU TexInfo, Groff man pages TeX formats: LaTeX, ConTeXt, ...
它是Java API,用于将使用MS Office(docx)或OpenOffice(odt),LibreOffice(odt)创建的XML文档与Java模型进行合并,以生成报告并将报告转换为其他格式(PDF,XHTML ...)。 请阅读样品和演示您可以测试我们的...
1、利用小美的Jacob调用MS Office转换文档为PDF 2、JCom是日本的一个开源项目,可以轻松实现office转换pdf 3、可以利用开源的OpenOffice,这个是linux提供的一个用于office的工具,调用内部API可以方便转换。 另外...