使用flexpaper在页面显示文档 |
您所在的位置:网站首页 › SWF文件解析器 › 使用flexpaper在页面显示文档 |
什么是flexpaper? FlexPaper是一个开源轻量级的在浏览器上显示各种文档的组件,被设计用来与PDF2SWF一起使用, 使在Flex中显示PDF成为可能,而这个过程并无需PDF软件环境的支持。它可以被当做Flex的库来使用。 首先,将pdf文件转换为swf(其他格式的文件需要先转换为pdf)。这里需要使用SwfTools。 SWFTools是一种实用工具与Adobe Flash文件(SWF文件)工作的集合。 该工具集包括用于阅读的SWF文件,结合他们,和他们建立从其他内容(如图像,声音文件,视频或源代码)程序。 SWFTools是在GPL下发布的。 SWFTools 是一组用来处理 Flash 的 swf 文件的工具包,包括: 1. 合并工具 swfcombine 2. 抽取工具 swfextract 3. PDF/JPEG/PNG/AVI/TTF/WAV 到 SWF 的转换工具 :pdf2swf, jpeg2swf, png2swf, avi2swf, font2swf, and wav2swf| 4. 文本解析工具 swfstrings 5. SWF 解析器 swfdump 6. SWF 读写库 rfxswflib。 使用命令将pdf文件转换为swf C:\SWFTools\pdf2swf Paper3.pdf -o Paper3.swf java实现将pdf转换为swf public static int convertPDF2SWF(String sourcePath, String destPath, String fileName) throws IOException { //目的文件夹 File dest = new File(destPath); if (!dest.exists()) { dest.mkdirs(); } // 源文件不存在则返回 File source = new File(sourcePath); if (!source.exists()) { return -1; } //cd 路径 String[] envp = new String[1]; envp[0] = "PATH="+SWFTOOLS_PATH; //SWFTOOLS_PATH为swftools的安装路径 //cmd 指令制定哪一个exe文件即可, String command = "cmd /c \""+SWFTOOLS_PATH+"pdf2swf\" -z -s flashversion=9 " + sourcePath + " -o " + destPath + fileName ; //System.out.println("command: " + command); //如果子进程应该继承当前进程的环境(path=),envp该参数为 null。 //String path = System.getProperty("java.library.path"); //其中每个元素的环境变量的设置格式为 name=value Process pro = Runtime.getRuntime().exec(command, envp); //获取子进程的输入流 BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(pro.getInputStream())); while (bufferedReader.readLine() != null) { //清空process.getInputStream()的缓冲区 //高级的做法是可以单独启动一个线程来做这件事 } // new Thread(new Runnable() { // public void run() { // BufferedReader br = new Buffered(new InputStreamReader(is)); // while(br.readLine() != null) ; // } // }.start(); try { //导致当前线程等待,如有必要,一直要等到由该 Process 对象表示的进程已经终止 pro.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } //返回子进程的出口值,但是输出流没有什么用,因为文件已经生成了 return pro.exitValue(); }下载flexpaper,解压到网页目录下 在页面调用flexpaper 在html的代码中声明一个标签 var fp = new FlexPaperViewer( 'flexpaper/FlexPaperViewer', 'viewerPlaceHolder', { config : { SwfFile : escape('paper.swf'), Scale : 0.6, ZoomTransition : 'easeOut', ZoomTime : 0.5, ZoomInterval : 0.2, FitPageOnLoad : true, FitWidthOnLoad : true,//适合初始页宽度大小的装载页 PrintEnabled : true, FullScreenAsMaxWindow : false, ProgressiveLoading : false, MinZoomSize : 0.2, MaxZoomSize : 5, SearchMatchAll : false, InitViewMode : 'Portrait', ViewModeToolsVisible : true, ZoomToolsVisible : true, NavToolsVisible : true, CursorToolsVisible : true, SearchToolsVisible : true, localeChain: 'zh_CN' }});
|
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |