java-flexpaper-swftools仿百度文库文档在线预览系统设计与实现学士学位论文.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《java-flexpaper-swftools仿百度文库文档在线预览系统设计与实现学士学位论文.doc》由会员分享,可在线阅读,更多相关《java-flexpaper-swftools仿百度文库文档在线预览系统设计与实现学士学位论文.doc(16页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Java FlexPaper swfTools_仿百度文库文档在线预览系统设计与实现最近在给客户开发文档管理系统时,客户要求上传到管理系统的文档(包括ppt,word,excel,txt)只能预览不允许下载。想到了百度文库和豆丁网,百度文库和豆丁网的在线预览都是利用flash来播放文档的,在网上查阅了大量资料,终于实现了该项功能,现将自己的设计和实现整理如下,自己可以试试。一、如何将文档转成flash支持的swf文件实现在线播放?1.先用openOffice把ppt、word、excel、txt类型的文档转换成pdf2.用swftools将pdf转换成swf,然后利用FlexPaper插件实现
2、在线播放预览。二、具体实现1.安装必备工具组件(1)安装openoffice,openoffice是开源免费的文字处理软件,它可以将office文档转成pdf文件(笔者安装到D:ProgramFiles),openOffice下载地址http:/www.openoffice.org/download/index.html(2)安装完openoffice后必须启动其server,以命令行方式启动openoffice server。进入cmd命令行提示符D:Program FilesOpenOffice.org 3program键入如下命令:soffice -headless -accept=so
3、cket,host=127.0.0.1,port=8100;urp; nofirststartwizard进入windows任务管理器查看有个进程soffice.bin,说明openoffice启动成功!(3)安装swfTools(安装到 D:Program Files)swftools作用是将pdf转换为swf文件以便flexpaper播放。下载地址:http:/www.swftools.org/download.html(4)下载flexpaper,下载地址:笔者下载的是FlexPaper_1.5.1,下载后将其解压备用。(5)下载OpenDocument文档转换器 JODConverte
4、r,JODConverter是一个java的OpenDucument文件转换器,可以进行许多文件格式的转换,它利用OpenOffice来进行转换工作,它能进行以下的转换工作:a.Microsoft Office格式转换为OpenDucument,以及OpenDucument转换为Microsoft Officeb.OpenDucument转换为PDF,Word、Excel、PowerPoint转换为PDF,RTF转换为PDF等。下载地址:我们后面开发主要用它的jodconverter-2.2.2.jar包2.软件开发过程(1)启动Eclipse,新建web项目名称为ctcesims(2)将上面
5、第4步解压的flexpaper文件中的js文件夹(包含了flexpaper_flash_debug.js,flexpaper_flash.js,jquery.js,这三个js文件主要是预览swf文件的插件)拷贝至网站根目录;将FlexPaperViewer.swf拷贝至网站根目录下(该文件主要是用在网页中播放swf文件的播放器),目录结构如下图(3)创建documentUpload.jsp文件htmlview plaincopy1. 3. 4. 5. 6. 7. 文档在线预览系统8. 9. bodymargin-top:100px;background:#fff;font-family:Ver
6、dana,Tahoma;10. acolor:#CE4614;11. #msg-boxcolor:#CE4614;font-size:0.9em;text-align:center;12. #msg-box.logoborder-bottom:5pxsolid#ECE5D9;margin-bottom:20px;padding-bottom:10px;13. #msg-box.titlefont-size:1.4em;font-weight:bold;margin:0030px0;14. #msg-box.navmargin-top:20px;15. 16. 17. 18. 19. 20. 2
7、1. 22. 请上传要处理的文件,过程可能需要几分钟,请稍候片刻。23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. (4)创建文档转换类DocConverter.javajavaview plaincopy1. packagecom.cectsims.util;2. importjava.io.BufferedInputStream;3. importjava.io.File;4. importjava.io.IOException;5. importjava.io.InputStream;6. 7. importcom.artofsolving.jodc
8、onverter.DocumentConverter;8. importcom.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;9. importcom.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;10. importcom.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;11. 12. /*13.
9、*docdocx格式转换14. */15. publicclassDocConverter16. privatestaticfinalintenvironment=1;/环境1:windows2:linux17. privateStringfileString;/(只涉及pdf2swf路径问题)18. privateStringoutputPath=;/输入路径,如果不设置就输出在默认的位置19. privateStringfileName;20. privateFilepdfFile;21. privateFileswfFile;22. privateFiledocFile;23. 24.
10、publicDocConverter(StringfileString)25. ini(fileString);26. 27. 28. /*29. *重新设置file30. *31. *paramfileString32. */33. publicvoidsetFile(StringfileString)34. ini(fileString);35. 36. 37. /*38. *初始化39. *40. *paramfileString41. */42. privatevoidini(StringfileString)43. this.fileString=fileString;44. fil
11、eName=fileString.substring(0,fileString.lastIndexOf(.);45. docFile=newFile(fileString);46. pdfFile=newFile(fileName+.pdf);47. swfFile=newFile(fileName+.swf);48. 49. 50. /*51. *转为PDF52. *53. *paramfile54. */55. privatevoiddoc2pdf()throwsException56. if(docFile.exists()57. if(!pdfFile.exists()58. Open
12、OfficeConnectionconnection=newSocketOpenOfficeConnection(8100);59. try60. connection.connect();61. DocumentConverterconverter=newOpenOfficeDocumentConverter(connection);62. converter.convert(docFile,pdfFile);63. /closetheconnection64. connection.disconnect();65. System.out.println(*pdf转换成功,PDF输出:+pd
13、fFile.getPath()+*);66. catch(.ConnectExceptione)67. e.printStackTrace();68. System.out.println(*swf转换器异常,openoffice服务未启动!*);69. throwe;70. catch(com.artofsolving.jodconverter.openoffice.connection.OpenOfficeExceptione)71. e.printStackTrace();72. System.out.println(*swf转换器异常,读取转换文件失败*);73. throwe;74.
14、 catch(Exceptione)75. e.printStackTrace();76. throwe;77. 78. else79. System.out.println(*已经转换为pdf,不需要再进行转化*);80. 81. else82. System.out.println(*swf转换器异常,需要转换的文档不存在,无法转换*);83. 84. 85. 86. /*87. *转换成swf88. */89. SuppressWarnings(unused)90. privatevoidpdf2swf()throwsException91. Runtimer=Runtime.getRu
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java flexpaper swftools 百度 文库 文档 在线 预览 系统 设计 实现 学士学位 论文
![提示](https://www.taowenge.com/images/bang_tan.gif)
链接地址:https://www.taowenge.com/p-92940015.html
限制150内