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
4星 · 超过85%的资源 需积分: 12 25 浏览量
2011-11-25
12:48:00
上传
评论 3
收藏 1.67MB RAR 举报
肖秋峰
- 粉丝: 7
- 资源: 67
最新资源
- 在matlab中通过yalmip平台调用cplex求解器,可用于求解MILP问题,适合于综合能源系统优化求解(注释完全,可直接运
- MT8852B labview 驱动,MT8852B labview 代码,蓝牙测试仪MT8852B代码,蓝牙低功耗测试
- 导照片2.0(只适合索尼微单)
- KMP算法python代码实现与使用场景.docx
- 基于MATLABCPLEX 的机组最优组合,成功求解表格化,图示化的机组组合结果(注释完全,可直接运行)(文档加Matlab源码
- postgresql-9.5.3-1-windows-x64
- 基于大数据和产业互联网的企业数字化转型.rar
- MySQL5与PHP5开发的相册系统源码.zip
- 支持linux CentOS安装 jdk1.8的jenkins
- Clover四叶草引导中文版
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页