新闻资讯 | 控件产品 | 技术文章 | 购物车 | 合作伙伴 | 问题解答 | 电子简报 | PDF论坛 | 资源下载
您现在的位置:技术文章>PDF开发篇 首页|PDF应用篇|PDF开发篇|解决方案

FlexPaper_1.2.1.swc——Flex在线显示PDF文档(使用FlexPaper)感悟

发布日期:2012-7-12 作者:aijingyi 出处:csdn

原文地址:http://blog.csdn.net/aijingyi/article/details/7723144

原文转自:http://www.cnblogs.com/wuhenke/archive/2010/03/16/1686885.html

想想自己先前搞PDF转SWF,然后在线浏览功能时,实在是费了不少精力。后来不断发现实现类似功能的网站:http://www.doc88.com/http://www.docin.com/ 虽然他们做的都比我起初做的好,但他们都是公司实力支撑,依靠的也是那种盈利模式。

自己的也在逐步完善和改进中,下面是我项目中的最终版:

 一直希望在项目结束后,分享我的代码和心得。前天碰巧看到有外国网友,将该功能封装成SWC,实现技术路线都是相同的,现在大家可以学习一下,很方便地实现自己的PDF在线浏览功能了。(功能还不错,但有待提高!如下:)

网站地址:

http://flexpaper.devaldi.com/index.php

介绍转载:

Introduction

FlexPaper is an open source light weight document viewer component designed to work together with libraries such as PDF2SWF, making it possible to display PDF files in Adobe Flex and other Flash based applications.

Making your document ready

To make it possible for your users to view your PDF documents without using Acrobat Reader, documents first needs to be converted to the SWF file format. There is a range of available converters, both commercial and free. The following example uses the open source tool SwfTools and can be automated if needed.

  1. Download and install SwfTools. All builds are available for downloadhere.
  2. Convert your PDF to SWF. This is preferrably done from the command prompt. Make sure you set your options (Edit->Options) to "No viewer" if you are converting your PDF using the UI from SwfTools before exporting your PDF to SWF. This example converts a PDF file called "Paper3.pdf" to the output file "Paper3.swf":
    C:\SWFTools\pdf2swf.exe Paper3.pdf -o Paper3.swf
    Please see the wiki for more details about the conversion and the parameters that are currently recommended.

Viewing your document using the pre compiled flash version

The pre-compiled version of FlexPaper is most useful if you just want to use FlexPaper on any of your web pages.

  1. Download and extract the pre-compiled version of FlexPaper. All builds are available for downloadhere.
  2. The zip file contains a sample file called "FlexPaperViewer.html" which shows you the basic parameters you need to pass to FlexPaper (SwfFile and Scale). Please see thewiki on Google Code for a complete list of available parameters.
  3. Copy the SWF you created with PDF2SWF to the same directory as your extracted files
  4. Upload everything to your web site and navigate to FlexPaperViewer.html in your favorite browser. If you on the other hand would like to run the application from a local directory rather than from a web server, then the application has to be added as trusted first. You can do that at Adobe's web site.

Using FlexPaper in Adobe Flex

Using the viewer in Adobe Flex is as easy a using the flash version.

  1. Download the FlexPaper SWC from Google Code and add the FlexPaper library to your Flex project.
  2. Copy the SWF you created with PDF2SWF to your bin-debug directory and add the FlexPaper component to your flex application as in the following example (update the SwfFile property on the component to point to your SWF file):
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" xmlns:fp="com.devaldi.controls.flexpaper.*">
    <fp:FlexPaperViewer width="520" height="450" Scale="0.6" SwfFile="Paper3.swf" /> </mx:Application>

国内介绍该控件库的先驱:

http://wangcheng.javaeye.com/blog/549074

转载其博客内容:

Flex:使用FlexPaper显示PDF文档

FlexPaper是一个开源的轻量级文档显示组件,被设计用来与PDF2SWF一起使用,使在Flex中显示PDF成为可能。它可以被当做Flex的library来使用。

一. 使用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版本浏览你的文档

  1. 下载并解压出已经编译好的FlexPaper
  2. zip文件包含一个例子文件叫做FlexPaperViewer.html,它向你展示了需要传给FlexPaper的基本参数
  1. var params = {
  2. SwfFile : "Paper.swf",
  3. Scale : 0.6
  4. }
  5. swfobject.embedSWF("FlexPaperViewer.swf","cb","500","500","9.0.0","js/swfobject/expressInstall.swf", params);
  6. //SwfFile参数是你想显示的文件,Scale是0-1之间的数,表示显示的放大参数

3. 复制你创建出来的swf和PDF2SWF到解压缩出的相同目录

4. 确定你添加了FlexPaperViewer.swf

三. 在Flex中使用FlexPaper

1. 下载FlexPaper SWC,添加到你的Flex项目libs中
2. 复制你用PDF2SWF创建的SWF到你的bin-debug目录,如Paper3.swf,添加FlexPaper组件到你的flex代码中


  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3. layout="absolute"
  4. width="800" height="500"
  5. xmlns:flexpaper="com.devaldi.controls.flexpaper.*">
  6. <flexpaper:FlexPaperViewer width="800" height="500"
  7. Scale="1" SwfFile="Paper3.swf" />
  8. </mx:Application>

原文 http://www.devaldi.com/?page_id=260
SwfTools http://www.swftools.org/download.html
flexpaper http://code.google.com/p/flexpaper/

另外附 我推荐的参考资料网址:

http://wiki.swftools.org/index.php/Main_Page#SWF_API_Documentation

http://wiki.swftools.org/index.php/Pdf2swf

http://wiki.swftools.org/index.php/How_do_I_create_a_AVM2_compatible_SWF%3F

http://wiki.swftools.org/index.php/How_do_I_highlight_text_in_the_SWF%3F

发布人:管理员 【报告错误】·【推荐好友】·【打印文章】
相关评论 本文现有 0 条评论 评分人数: 0 平均分: 0
相关评论
用户名: 密  码:
说明:输入正确的用户名和密码才能参与评论。如果您不是本站会员,你可以注册为本站会员。
注意:文章中的链接、内容等需要修改的错误,请用报告错误,以利文档及时修改。
注意:请不要在评论中含与内容无关的广告链接,违者封ID
文章搜索
推荐文章
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
循序渐进学习iTextShar
热门点击
一个简单的PDF文件结构的分析(22751)
PHP的FDF文档支持(16274)
用C#制作PDF文件全攻略(13703)
Word转换PDF格式的C#或(12213)
ITextRenderer学习(11749)
pdfMaker文章:PDF加(11696)
PDF文件加密仿真(11114)
怎样用iReport制作Web(10483)
iText PDF概述(1)(10077)
从pdf文档中提取出文本(10016)
热门评论
从pdf文档中提取出文本(8)
PDFlib开发:创建超文本元(2)
客户端自动打印PDF(Prin(2)
浅谈PDFlib中文输出(一)(2)
xml的转换之pdf 2 ((1)
xml的转换之pdf 1 (x(1)
PDF知识讲座(1)(1)
PDFBox使用简介(1)
使用正则表达式计算PDF文档的(1)
word转pdf(1)