flexpaper在线预览问题javalinuxoffice文件在线预览的时候出现如图的问题,不能预览,求大神帮忙

author author     2023-04-18     326

关键词:

参考技术A swftools-0.9.1.exe 和 FlexPaper_1.4.5_flash.zip,工具网上下载。
二、PDF转换SWF文件核心类:

public class DocConverter
private static final int environment = 1;// 环境1:windows,2:linux(涉及pdf2swf路径问题)
private String fileString;
private String outputPath = "";// 输入路径,如果不设置就输出在默认位置
private String fileName;
private File pdfFile;
private File swfFile;
private File docFile;

public DocConverter(String fileString)
ini(fileString);


/*
* 重新设置 file @param fileString
*/
public void setFile(String fileString)
ini(fileString);


/*
* 初始化 @param fileString
*/
private void ini(String fileString)
this.fileString = fileString;
fileName = fileString.substring(0, fileString.lastIndexOf("."));
docFile = new File(fileString);
pdfFile = new File(fileName + ".pdf");
swfFile = new File(fileName + ".swf");


/*
* 转为PDF @param file
*/

/*
* 转换成swf
*/
private void pdf2swf() throws Exception
Runtime r = Runtime.getRuntime();
if (!swfFile.exists())
if (pdfFile.exists())
if (environment == 1)// windows环境处理

try
// 这里根据SWFTools安装路径需要进行相应更改
Process p = r.exec("G:/Program Files/SWFTools/pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.out.print(loadStream(p.getInputStream()));
System.err.println("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
if (pdfFile.exists())
// pdfFile.delete();

catch (Exception e)
e.printStackTrace();
throw e;

else if (environment == 2)// linux环境处理

try
Process p = r.exec("pdf2swf " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.err.println("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
if (pdfFile.exists())
pdfFile.delete();

catch (Exception e)
e.printStackTrace();
throw e;


else
System.out.println("****pdf不存在,无法转换****");

else
System.out.println("****swf已存在不需要转换****");



static String loadStream(InputStream in) throws IOException
int ptr = 0;
//把InputStream字节流 替换为BufferedReader字符流 2013-07-17修改
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder buffer = new StringBuilder();
while ((ptr = reader.read()) != -1)
buffer.append((char) ptr);

return buffer.toString();


/*
* 转换主方法
*/
public boolean conver()
if (swfFile.exists())
System.out.println("****swf转换器开始工作,该文件已经转换为swf****");
return true;


if (environment == 1)
System.out.println("****swf转换器开始工作,当前设置运行环境windows****");
else
System.out.println("****swf转换器开始工作,当前设置运行环境linux****");


try
// doc2pdf();
pdf2swf();
catch (Exception e)
// TODO: Auto-generated catch block
e.printStackTrace();
return false;


if (swfFile.exists())
return true;
else
return false;



/*
* 返回文件路径 @param s
*/
public String getswfPath()
if (swfFile.exists())
String tempString = swfFile.getPath();
tempString = tempString.replaceAll("\\\\", "/");
return tempString;
else
return "";



/*
* 设置输出路径
*/
public void setOutputPath(String outputPath)
this.outputPath = outputPath;
if (!outputPath.equals(""))
String realName = fileName.substring(fileName.lastIndexOf("/"), fileName.lastIndexOf("."));
if (outputPath.charAt(outputPath.length()) == '/')
swfFile = new File(outputPath + realName + ".swf");
else
swfFile = new File(outputPath + realName + ".swf");





三、JSP文件,注意引入的几个js文件和FlexPaperViewer.swf文件,其中FlexPaperViewer.swf和jsp文件放在同一目录即可。

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String paths=(String)request.getAttribute("swfpath");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>te</title>

<style type="text/css" media="screen">
html, body height:100%;
body margin:0; padding:0; overflow:auto;
#flashContent display:none;
</style>

<script type="text/javascript" src="<%=basePath %>js/swfobject/swfobject.js"></script>
<script type="text/javascript" src="<%=basePath %>js/flexpaper_flash.js"></script>
<script type="text/javascript">
//<!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
var swfVersionStr = "10.0.0";
//<!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
/* var xiSwfUrlStr = "playerProductInstall.swf"; */
var xiSwfUrlStr = ""; //值可以任意

var flashvars =
SwfFile : escape("<%=basePath+paths%>"), //swf文件路径(lucene4.6和页面同一个位置)
Scale : 0.6,
ZoomTransition : "easeOut",
ZoomTime : 0.5,
ZoomInterval : 0.1,
FitPageOnLoad : false,
FitWidthOnLoad : true,
PrintEnabled : true,
FullScreenAsMaxWindow : false,
ProgressiveLoading : true,

PrintToolsVisible : true,
ViewModeToolsVisible : true,
ZoomToolsVisible : true,
FullScreenVisible : true,
NavToolsVisible : true,
CursorToolsVisible : true,
SearchToolsVisible : true,

localeChain: "en_US"
;

var params =


params.quality = "high";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = ;
attributes.id = "FlexPaperViewer";
attributes.name = "FlexPaperViewer";
swfobject.embedSWF(
"FlexPaperViewer.swf", "flashContent",
"1024", "700",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display:block;text-align:center;");
</script>

</head>
<body>

<div style="width: 100%;height: 90%; text-align: center;">
<div id="flashContent">
</div>
</div>

</body>
</html>追问

额,我的类啥的都没有问题,刚开始的时候是正常的,后来就报了那个错

参考技术B 你解决了么 怎么解决的

《java+flexpaper+swftools仿百度文库文档在线预览系统设计与实现》

Java+FlexPaper+swfTools仿百度文库文档在线预览系统设计与实现笔者最近在给客户开发文档管理系统时,客户要求上传到管理系统的文档(包括ppt,word,excel,txt)只能预览不允许下载。笔者想到了百度文库和豆丁网,百度文库和豆丁... 查看详情

word,excel,ppt转pdf,pdf转swf,通过flexpaper+swftools实现在线预览

自己上网查了好多种方法,最后还是选了这种不收费,还挺好用的方法      为了用户有一个好的体验我将word、excel、ppt转Pdf,Pdf转Swf写在服务上,因为我当时做的时候Pdf转Swf会执行pdf2swf.exe弹出黑框,对用户... 查看详情

word/excel在线预览

...,然后再使用pdf2swf转换为swf文件,也就是flash文件在使用FlexPaper展示出来(优点:预览效果能接受,缺点:代码量大) ③使用Officeonline(优点:表现完美, 查看详情

javaweboffice文档在线预览怎么实现!!!

...么实现!!!在线预览的不是office格式,而且是swf文件,flexPaper是可以把swf放在页面上进行展示的,1、flash的flexpaper将文档转换为swf格式,然后使用flash在网页中浏览,2、使用开源的软件openoffice+pdf2htmlEx,利用openoffice的接口先... 查看详情

jsp有办法实现word/excel的在线预览吗

参考技术A后台调用openoffice服务将office文档转换为PDF文档,再使用pdf2swf插件将PDF文档转换为SWF文档,将生成的SWF文档的路径传递给JSP页面上的FlexPaper的参数就可以了。可以去百度文库中搜索相关资料进行实践。 查看详情

用java做一个word和excel的在线预览功能,跪求代码

...显示office和pdf,最常见的方法就是把都转为swf,然后通过FlexPaper显示。这个方法有缺点,FlexPaper不支持所有浏览器(我只能在chrome中使用,firefox要进行设置)我用的系统是Ubuntu13.1064位一下所提到的软件,我都会在附件中分享一... 查看详情

在线问题反馈模块实战​:实现图片预览功能

查看详情

flexpaper查看flash文件

HTML代码:<head>   <metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">   <title>Flash在线阅览</title>  <scripttype="text/javascript"src="../static/widgets/flashpaper/f 查看详情

产品三维模型在线预览

产品在线展示案例预览玉镯在线预览:http://www.yanhuangxueyuan.co...汽车在线预览:http://www.yanhuangxueyuan.co...Web3D技术历史可通过插件或WebGL技术实现Web3D,在线网页上预览操作三维模型。插件最早实现Web3D技术所有技术方案,基本都要... 查看详情

实现在线预览pdf的几种解决方案(代码片段)

原文:实现在线预览PDF的几种解决方案因客户需要实现PDF的预览处理,在网上找了一些PDF在线预览的解决方案,有的用PDFJS的在线预览方式,有的使用PDFObject的嵌入式显示,有的通过转换JPG/PNG方式实现间接显示的方式,开始是想... 查看详情

vue-pdf.js在线预览问题

参考技术A最近修改公司vue项目中使用pdf.js来实现在线预览上传的各类文件.由于使用pdf.js在预览时是直接在标签内将src属性赋值为要请求的地址.这就导致一个问题,会直接请求服务器的文件路径地址,而这个服务器文件路径就会暴... 查看详情

在线预览word,excel

今天在项目中遇到了在线预览word的需求,经过查阅资料与测试发现可以解决问题,特做记录:方式:http://view.officeapps.live.com/op/view.aspx?src=src后面填写你上传的文件地址,例如:https://view.officeapps.live.com/op/view.aspx?src=http://opd9w8mwo.bk... 查看详情

flexpaper 默认的两页视图设置

】flexpaper默认的两页视图设置【英文标题】:flexpaperdefaulttwopageviewsettings【发布时间】:2011-07-2123:39:37【问题描述】:我正在使用flexpage和pdf2swf为我的pdf文件生成swf并将其显示在我的页面中。这是我使用的设置<scripttype="text/java... 查看详情

一文教你优雅落地在线预览服务(代码片段)

在日常开发中,在线预览是一个很常见的功能。在最开始调研时,博主选择自己实现,但是有以下问题。需要预览的类型太多,很多类型需要不同的预览方式。开发成本较大。格式调整不理想。而且博主公司需求... 查看详情

在线问题反馈模块实战​:实现图片预览功能(代码片段)

👨‍🎓作者:bug菌✏️博客:CSDN、掘金等💌公众号:猿圈奇妙屋🚫特别声明:原创不易,转载请附上原文出处链接和本文声明,谢谢配合。🙏版权声明:文章里可能部分文字或者... 查看详情

在线问题反馈模块实战​:实现图片预览功能(代码片段)

👨‍🎓作者:bug菌✏️博客:CSDN、掘金等💌公众号:猿圈奇妙屋🚫特别声明:原创不易,转载请附上原文出处链接和本文声明,谢谢配合。🙏版权声明:文章里可能部分文字或者... 查看详情

怎样在线预览word文档

...页面,我们就可以使用永中DCS文档转换小工具,简单3步在线预览常见的Office文档、PDF版式文档、Zip压缩文件。当然,也支持.doc/.docx格式的Word文件。第一步(Step1):添加文件(上传需要预览的Word文件)上传有两种模式,一是本... 查看详情

excel转html实现在线预览

首先说一下,本人发布的代码都是经过本人亲测,并且用在实际项目中。如果觉得可以,希望大家点个赞,谢谢大家。有什么问题,大家评论出来,一起交流。好了,不废话了,下面来说一说这个东西怎么做。网上也有许多版本... 查看详情