package com.chinacreator.test;
import java.io.File;
import java.net.ConnectException;
import java.util.Date;
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;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
public class JOD4DocToPDF {
public void docToPdf(File inputFile, File outputFile){
Date start = new Date();
// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try{
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
}catch(ConnectException cex){
cex.printStackTrace();
}finally{
// close the connection
if(connection!=null){
connection.disconnect();
connection = null;
}
}
long l = (start.getTime()- new Date().getTime());
long day=l/(24*60*60*1000);
long hour=(l/(60*60*1000)-day*24);
long min=((l/(60*1000))-day*24*60-hour*60);
long s=(l/1000-day*24*60*60-hour*60*60-min*60);
System.out.println("生成"+outputFile.getName()+"耗费:"+min+"分"+s+"秒");
}
class TestThread extends java.lang.Thread{
public File inputFile;
public File outputFile;
public void run(){
JOD4DocToPDF t = new JOD4DocToPDF();
t.docToPdf(inputFile, outputFile);
System.out.println(outputFile.getName()+"文件已生成");
}
}
public void test(String path,String st){
TestThread t1 = new TestThread();
t1.inputFile = new File(path+st+".doc");
// t1.inputFile = new File(path+st+".xls");
t1.outputFile = new File(path+st+".pdf");
//
// TestThread t2 = new TestThread();
// t2.inputFile = new File("d:/document2.doc");
// t2.outputFile = new File("d:/document2.pdf");
//
// TestThread t3 = new TestThread();
// t3.inputFile = new File("d:/document3.doc");
// t3.outputFile = new File("d:/document3.pdf");
// t2.start();
t1.start();
// t3.start();
}
public static void main(String[] args) throws Exception{
String Path="D:\\";//转换的文件路径
String str="中国2s";//转换的文件名称
Converter c = new Converter();
System.out.println("start");
String sourcePath = Path+str+".pdf";
String destPath = Path;
String fileName = str+".swf";
try{
JOD4DocToPDF p = new JOD4DocToPDF(); //生成pdf
p.test(Path,str);
Converter.convertPDF2SWF(sourcePath, destPath, str);//生成swf
}catch(Exception ex)
{
System.out.println("error");
}
System.out.println("success");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
(Linux,window)openOffice+pdf2swf+flexpaper
共19个文件
jar:11个
class:4个
java:2个
4星 · 超过85%的资源 需积分: 12 69 下载量 51 浏览量
2011-11-25
12:48:00
上传
评论 3
收藏 1.67MB RAR 举报
温馨提示
本人刚做了个项目,实现功能Linux,window)openOffice+pdf2swf+flexpaper(类百度文库) :
资源推荐
资源详情
资源评论
收起资源包目录
openOffice++flexpaper+pdf2swf.rar (19个子文件)
JODConverterDoc2PDF
.project 395B
src
com
chinacreator
test
JOD4DocToPDF.java 3KB
Converter.java 3KB
lib
xstream-1.2.2.jar 364KB
commons-io-1.3.1.jar 82KB
jodconverter-cli-2.2.1.jar 5KB
jurt-2.3.0.jar 111KB
jodconverter-2.2.1.jar 31KB
slf4j-jdk14-1.4.3.jar 8KB
slf4j-api-1.4.3.jar 15KB
commons-cli-1.0.jar 29KB
juh-2.3.0.jar 58KB
ridl-2.3.0.jar 245KB
unoil-2.3.0.jar 1.2MB
.classpath 905B
bin
com
chinacreator
test
Converter$1.class 1KB
Converter.class 3KB
JOD4DocToPDF.class 2KB
JOD4DocToPDF$TestThread.class 805B
共 19 条
- 1
肖秋峰
- 粉丝: 7
- 资源: 67
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页