導航:首頁 > 版本升級 > flex實現文件下載

flex實現文件下載

發布時間:2023-07-30 01:35:31

1. 如何使用FLEX在線顯示WORD文檔 或PDF文件

一. 使用PDF2SWF准備好你的文檔
首先要將PDF轉成SWF,這步可以使用開源的SwfTools自動完成
1.下載安裝 SwfTools,當前最新版本是0.9
2. 轉換PDF到SWF,可以通過命令行的方式,例如將Paper3.pdf轉換成Paper3.swf
C:\SWFTools\pdf2swf Paper3.pdf -o Paper3.swf
二. 使肆備用已裂閉毀經編譯好的FlexPaper的flash版本瀏覽你的文檔
下載並解壓出已經編譯好的FlexPaper
zip文件包含一個例子文件叫做FlexPaperViewer.html,它向你展示了需要傳給FlexPaper的 基本參數
var params = {
SwfFile : "Paper.swf",
Scale : 0.6
}
swfobject.embedSWF("FlexPaperViewer.swf","cb","500","500","9.0.0","js/swfobject/expressInstall.swf", params);

//SwfFile參數是你想顯示的文件,Scale是0-1之間的數,表示顯示的放大參數
復制你創建出來的swf和PDF2SWF到解壓縮出的相同目錄
確定你添加了FlexPaperViewer.swf
三. 在Flex中使用FlexPaper
1. 下載FlexPaper SWC,添加到你的Flex項目libs中
2. 復制你用PDF2SWF創建的SWF到你的bin-debug目錄,如Paper3.swf,添加FlexPaper組 件到你的flex代碼中Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="800" height="500"
xmlns:flexpaper="com.devaldi.controls.flexpaper.*">

<flexpaper:FlexPaperViewer width="800" height="500"
Scale="1" SwfFile="Paper3.swf" />

</mx:Application>

網友寫的一個方法可以利用java轉化pdf為swf:

[java] view plain
/**
* 將pdf文件轉化成swf文件
* @param fileName 文件的絕對路徑
* @param destPath 目標路徑
* @return -1:源文件不存在,-2:格式不正確,-3:發生異常,0:轉化成功
* @author fanglm created on Jul 9, 2010 1:13:04 PM
*/
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 = "D://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;
}
}

閱讀全文

與flex實現文件下載相關的資料

熱點內容
photoshopcs6教程哪個好 瀏覽:345
java獲取object類型 瀏覽:944
怎麼將兩組相同數據放在一列 瀏覽:793
錢包的dapp和網站有什麼區別 瀏覽:739
基本戶密碼忘了怎麼辦 瀏覽:51
用電腦怎麼壓縮文件 瀏覽:969
重裝系統後桌面的隱藏文件桌面回復 瀏覽:708
蘋果5設置描述文件 瀏覽:875
qq游戲蛇蛇爭霸閃退 瀏覽:639
stdioh源代碼 瀏覽:504
怎麼數文件夾一個詞語出現多少次 瀏覽:334
桌面把多個文件夾圈在一起 瀏覽:997
網站首頁彈出公告代碼 瀏覽:345
如何輸入網路憑據連接別的電腦 瀏覽:785
word2007自選圖形在哪 瀏覽:482
暴風魔鏡硬碟文件 瀏覽:632
c語言冒泡排序頭文件 瀏覽:159
固網移動網路架構 瀏覽:192
計算機文件擴展名多少位 瀏覽:373
java實現詞雲 瀏覽:520

友情鏈接