类似百度文档库的flash播放器FlexPaper

你可以从[url]http://flexpaper.googlecode.com/svn/trunk[/url]上下载flexpaer播放器,还有源码 ,用要SVN检出,
1 :下载openoffice,安装到本机,然后能过命令行打开服务
cd C:\Program Files\OpenOffice.org 3\program
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

在程序中你可以能过代码将word,txt,...数据源转化成Pdf格式的,
这是测试代码:

public static void main(String[] args) {

File inputFile = new File("D:\\新建文件夹 (2)\\河南分公司“创先争优”活动简报 第一期.doc");
File outputFile = new File("D:\\新建文件夹 (2)\\河南分公司“创先争优”活动简报 第一期.pdf");

// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
} catch (ConnectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
// close the connection


connection.disconnect();

}

2:安装swftoos到本机,可以能过代码将pdf格式 的文件转化成swf
public static int ConvertPdfToSwf(String fileName,String destPath){
String destName = "",fileExt = "";
StringBuffer command = new StringBuffer();
fileExt = fileName.split("\\.")[fileName.split("\\.").length-1].toLowerCase();
try{
File file = new File(fileName);
if(!file.exists()){//判断源文件是否存在
return 1;
}else if(!fileExt.equals("pdf")){//判断文件是否是pdf格式的文件
return 2;
}
else{
String swftoolsPath = "C:\\Program Files\\SWFTools";//获取pdf转swf工具的路径
if(!swftoolsPath.substring(swftoolsPath.length()-1, swftoolsPath.length()).equals("\\")){
swftoolsPath = swftoolsPath+"\\"; //在目录后加 "\"
}
if(!destPath.substring(destPath.length()-1, destPath.length()).equals("\\")){
destPath = destPath+"\\"; //在目录后加 "\"
}
File destFile = new File(destPath);
if(!destFile.exists()){//目标文件路径如果不存在,则创建目录
destFile.mkdirs();
}
destName = file.getName().substring(0, file.getName().length()-4)+".swf";//目标文件名称
command.append(swftoolsPath).append("pdf2swf.exe ").append(fileName).append(" -o ").append(destPath).append(destName);
Process pro = Runtime.getRuntime().exec(command.toString());
BufferedReader buffer = new BufferedReader(new InputStreamReader(pro.getInputStream()));
while(buffer.readLine()!=null);
return pro.exitValue();
}
}catch (Exception e){
e.printStackTrace();
return 3;
}
3:最后再把Exmple/FlexPaperViewer.html里面的SwfFile : escape("20100826124510.swf?v1.4.0rc2-refresh2"),文件名改成你要播放的那个swf,就可以看到效果了,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值