仿百度,豆瓣读书文库阅读器
2012-02-12 20:24
560人阅读
评论(2)
收藏
举报
FlexPaper是一个开源轻量级的在浏览器上显示各种文档的组件,被设计用来与PDF2SWF一起使用, 使在Flex中显示PDF成为可能,而这个过程并无需PDF软件环境的支持。它可以被当做Flex的库来使用。 另外你也可以通过将一些例如Word、PPT等文档转成PDF,然后实现在线浏览。 利用 FlexPaper 基于Flex实现,可以在线浏览PDF文档,而不要PDF软件支持。它支持的扩展名就是.swf,所以再需要一款软件,使得PDF自动转换为SWF格式。它就是 swftools 。操作很简单,首先第一步:
下载swftools
http://www.swftools.org/download.htm
安装后可以先试下里面的命令
C:SWFToolspdf2swf Paper3.pdf -o Paper3.swf
当然安装目录自己指定,Papaer3.pdf也是自己指定路径。
第二步:下载
http://flexpaper.devaldi.com/download/Flash版本
下载完后打开可以发现里面有个index.html,查看内容可以得到一段script脚本
<script type="text/javascript" src="js/flexpaper_flash.js"></script>
??? </head>
??? <body>
??? <div style="position:absolute;left:10px;top:10px;">
?????? <a id="viewerPlaceHolder" style="width:680px;height:480px;display:block"></a>
??????
?????? <script type="text/javascript">
var fp = new FlexPaperViewer(
'FlexPaperViewer',
'viewerPlaceHolder',{ config : {
SwfFile : escape('Paper.swf'),204); border-bottom-width:1px; border-bottom-style:dashed">
Scale : 0.6,204); border-bottom-width:1px; border-bottom-style:dashed">
ZoomTransition : 'eaSEOut',204); border-bottom-width:1px; border-bottom-style:dashed">
ZoomTime : 0.5,204); border-bottom-width:1px; border-bottom-style:dashed">
ZoomInterval : 0.2,204); border-bottom-width:1px; border-bottom-style:dashed">
FitPageOnLoad : true,204); border-bottom-width:1px; border-bottom-style:dashed">
FitWidthOnLoad : false,204); border-bottom-width:1px; border-bottom-style:dashed">
FullScreenAsMaxWindow : false,204); border-bottom-width:1px; border-bottom-style:dashed">
ProgressiveLoading : false,204); border-bottom-width:1px; border-bottom-style:dashed">
MinZoomSize : 0.2,204); border-bottom-width:1px; border-bottom-style:dashed">
MaxZoomSize : 5,204); border-bottom-width:1px; border-bottom-style:dashed">
SearchMatchAll : false,204); border-bottom-width:1px; border-bottom-style:dashed">
InitViewMode : 'Portrait',204); border-bottom-width:1px; border-bottom-style:dashed">
PrintPaperAsBitmap : false,204); border-bottom-width:1px; border-bottom-style:dashed">
ViewModeToolsVisible : true,204); border-bottom-width:1px; border-bottom-style:dashed">
ZoomToolsVisible : true,204); border-bottom-width:1px; border-bottom-style:dashed">
NavToolsVisible : true,204); border-bottom-width:1px; border-bottom-style:dashed">
CursorToolsVisible : true,204); border-bottom-width:1px; border-bottom-style:dashed">
SearchToolsVisible : true,204); border-bottom-width:1px; border-bottom-style:dashed">
? localeChain: 'en_US'
}});
?????? </script>
??????? </div>
参数基本可以参考英文,里面的Paper.swf就是调用的文件。
我现在放一个自己的PDF文件,然后运行这段程序可以看到
很简单的,如果没有加载文件,那么就是要到
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html#119065
将文件添加为信任才行。
一. 使用PDF2SWF准备好你的文档 首先要将PDF转成SWF,这步可以使用开源的SwfTools自动完成 1.下载安装 SwfTools,当前最新版本是0.9 二. 使用已经编译好的FlexPaper的flash版本浏览你的文档
三. 在Flex中使用FlexPaper 1. 下载FlexPaper SWC,添加到你的Flex项目libs中 <?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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |