日期:2014-05-17  浏览次数:20755 次

JAVA实现百度文库为什么flexpaper加载不了啊,求助
package servlet;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

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 ConvertServlet extends HttpServlet{
private File sourceFile; //转换源文件
private File pdfFile; //PDF目标文件
private File swfFile; //SWF目标文件
private Runtime r;

public void init() throws ServletException {
sourceFile = new File("E:/apache-tomcat-6.0.37/webapps/readonline/swfFile/项目数据库表2.doc");
pdfFile = new File("E:/apache-tomcat-6.0.37/webapps/readonline/swfFile/项目数据库表2.pdf");
swfFile = new File("E:/apache-tomcat-6.0.37/webapps/readonline/swfFile/项目数据库表2.swf");
System.out.println("第一步:生成文件对象,准备转换");
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doPost(req, resp);
}

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
//转换成pdf文件
if(sourceFile.exists()) {
if(!pdfFile.exists()) {
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);   
converter.convert(sourceFile, pdfFile);
pdfFile.createNewFile();
connection.disconnect();  
System.out.println("第二步:转换为PDF格式 路径" + pdfFile.getPath());
} catch (java.net.ConnectException e) {
e.printStackTrace();
System.out.println("OpenOffice服务未启动");
throw e;
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
e.printStackTrace();
System.out.println("读取文件失败");
throw e;
} catch (Exception e){
e.printStackTrace();
try {
throw e;
} catch (Exception e1) {
e1.printStackTrace();
}
}
} else {
System.out.println("已转换为PDF,无需再次转换");
}
} else {
System.out.println("要转换的文件不存在");

//转换成swf文件
r = Runtime.getRuntime();
if(!swfFile.exists()){
if(pdfFile.exists()) {
try {
Process p = r.exec("D:/swftools/pdf2swf