首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JAVA实现百度文库为什么flexpaper加载不了啊

2013-11-29 
JAVA实现百度文库为什么flexpaper加载不了啊,求助package servletimport java.io.Fileimport java.io.IO

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.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
p.waitFor();
swfFile.createNewFile();
System.out.println("第三步:转换为SWF格式路径:" + swfFile.getPath());
System.out.println("第si步:转换为SWF格式mingcheng:" + swfFile.getName());
if(pdfFile.exists()) {
pdfFile.delete();
}
} catch (Exception e) {
e.printStackTrace();
try {
throw e;
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
} else {
System.out.println("PDF文件不存在,无法转换");
}
} else {
System.out.println("已经转为SWF文件,无需再次转换");
}
HttpSession session = req.getSession();
session.setAttribute("fileName", swfFile.getName());
resp.sendRedirect(req.getContextPath()+"/flexpaper/readFile.jsp");
}
}

转换成功了,但是在jsp页面却怎么也显示不出来,一直都是一个圈在转,等待,


我这里也让他转换成版本9了,可还是不行啊Process p = r.exec("D:/swftools/pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
用他自带的就可以,这是为什么??
[解决办法]
我刚做完这个,你是不是在Adobe Flash的官网没有设置允许?
[解决办法]
一、cmd去生成一个swf文件,放在flexpaper路径下,看是否能正常显示
二、生成swf之前,加入xpdf编码--》-s languagedir=xxx
三、确认swftools是否为最新的0.9.1

热点排行