关于FlexPaper分页加载,我debug调试发现在 pdf2SWF这个方法执行完成,也就是600页的PDF全部分页转成SWF才能返回到前台完成显示,能不能有什么方法在第一页转成的时候就返回前台,这样就能先显示第一页,剩下的转成一个分页SWF返回前台一个,这样效率才高。请高手指教,谢谢!!!
前台代码如下:
$(function(){
$.ajax({
type:'post',
data:{},
url:'${ct}/pdfToSwf.tool?wjDm=${param.wjDm}',
dataType:'json',
success:function(data){
/* success 表示是否成功 url 返回的路径 */
if(data.success){
$('#documentViewer').FlexPaperViewer(
{ config : {
jsDirectory:path+"plugins/FlexPaper_2.2.4",//路径
// SWFFile :path+ "upload/"+data.url,
SWFFile:path + "upload/"+ "{Paper[*,0].swf,604}",
Scale : 0.9,
ZoomTransition : 'easeOut',
ZoomTime : 0.5,
ZoomInterval : 0.2,
FitPageOnLoad : true,
FitWidthOnLoad : true,
FullScreenAsMaxWindow : false,
ProgressiveLoading : false,
MinZoomSize : 0.2,
MaxZoomSize : 5,
SearchMatchAll : false,
InitViewMode : 'Portrait',
RenderingOrder : 'flash',
StartAtPage : '',
ViewModeToolsVisible : true,
ZoomToolsVisible : true,
NavToolsVisible : true,
CursorToolsVisible : true,
SearchToolsVisible : true,
WMode : 'window',
localeChain: 'zh_CN'
}}
);
后台java代码
XtJzMx xtJzMx = ftpService.getFtpFile(wjDm);
String wjgs = xtJzMx.getWjGs();
sourceFile = xtJzMx.getFiles(wjgs);
//sourceFile =C:\Users\ADMINI~1\AppData\Local\Temp\9c425c20-f9b6-4f69-b990-d6aab0885f6b
//File sourceFile = new File(filePath, "Paper.pdf");
String destFileName = /*UUID.randomUUID().toString() +*/ "Paper%.swf";
//destFileName =9e6b63bd-30d0-4d8f-9c41-f89459fc9b0ePaper%.swf {filename[*,0],total pages}
File destFile = new File(filePath, destFileName);
//E:\Workspaces\seas-web\\main\\upload\9e6b63bd-30d0-4d8f-9c41-f89459fc9b0ePaper%.swf
int convertResult = pdf2SWF(sourceFile, destFile);
String result = "";
if (convertResult != 0) {
result = "{\"success\":false}";
} else {
result = "{\"success\":true,\"url\":\"" + destFileName + "\"}";
}
out.write(result);
我debug调试发现在 pdf2SWF这个方法执行完成,也就是600页的PDF全部分页转成SWF才能返回到前台完成显示,能不能有什么方法在第一页转成的时候就返回前台,这样就能显示第一页了。
pdf2SWF方法如下:
// 调用pdf2swf命令进行转换swfextract -i - sourceFilePath.pdf -o
// destFilePath.swf
String command = SWFTools_HOME + " -i " + sourceFile + " -o "
+ destFile+" -T 9 -t -s storeallcharacters";
Process pro = Runtime.getRuntime().exec(command);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(pro.getInputStream()));
while (bufferedReader.readLine() != null) {
}
pro.waitFor();
return pro.exitValue();
在BufferedReader这个方法的时候开始转swf的。