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

简介:

想想自己先前搞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 download here.
  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 download here.
  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 the wiki 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 atAdobe'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.   
    7. //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.        
  7.     <flexpaper:FlexPaperViewer width="800" height="500"    
  8.         Scale="1" SwfFile="Paper3.swf" />  
  9.        
  10. </mx:Application>  

 


本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/4203005.html,如需转载请自行联系原作者

相关文章
|
5月前
|
存储 JSON API
如何将 Swagger 文档导出为 PDF 文件
你会发现自己可能需要将 Swagger 文档导出为 PDF 或文件,以便于共享和存档。在这篇博文中,我们将指导你完成将 Swagger 文档导出为 PDF 格式的过程。
|
7月前
|
人工智能 编解码 文字识别
OCRmyPDF:16.5K Star!快速将 PDF 文件转换为可搜索、可复制的文档的命令行工具
OCRmyPDF 是一款开源命令行工具,专为将扫描的 PDF 文件转换为可搜索、可复制的文档。支持多语言、图像优化和多核处理。
847 17
OCRmyPDF:16.5K Star!快速将 PDF 文件转换为可搜索、可复制的文档的命令行工具
|
6月前
|
人工智能 文字识别 自然语言处理
1.6K star!这个开源文本提取神器,5分钟搞定PDF/图片/Office文档!
Kreuzberg 是一个基于 Python 的文本提取库,支持从 PDF、图像、Office 文档等 20+ 格式中提取文本内容。采用 MIT 开源协议,具备本地处理、异步架构、智能 OCR 等特性,特别适合需要隐私保护的文档处理场景。
385 1
DeepSeek + Xmind,1分钟自动把pdf/word文档转成思维导图
DeepSeek与Xmind结合,1分钟将PDF、Word文档转换为思维导图。只需四步:上传文档至DeepSeek,请求转换为Markdown格式,保存文件并修改后缀为.md,最后导入Xmind生成思维导图。轻松驾驭复杂文档,适用于学习笔记、工作报告、项目规划等场景,大幅提升效率!
|
数据挖掘 程序员 数据安全/隐私保护
解锁PDF潜力:9个Python库让你的文档处理更高效
程序员晚枫分享了Python处理PDF的9个第三方库,包括PyPDF2、pdfrw、ReportLab、pikepdf、pdfplumber、pdfminer.six、PyMuPDF、popdf和borb,各具优缺点。选择时需考虑应用场景、功能需求、库的维护状态和开源协议。例如,pdfplumber擅长内容提取,而ReportLab和PyMuPDF适用于创建和修改内容。
1865 7
|
9月前
|
存储 运维 安全
《VERICUT 9.X电脑配置要求与安装说明(官方)》—— PDF文档
本文档详细介绍了 CGTech Vericut 9.X 的安装指南,涵盖安装前准备、安装流程、系统要求、故障排除、许可证配置及多种接口配置等内容,为用户提供全面的软件安装与配置指导。
333 3
|
10月前
|
API C#
在.NET中使用QuestPDF高效地生成PDF文档
在.NET中使用QuestPDF高效地生成PDF文档
246 0
|
开发框架 前端开发 JavaScript
在Winform分页控件中集成导出PDF文档的功能
在Winform分页控件中集成导出PDF文档的功能
[PDF提取重命名]提取识别文字并对PDF文件批量重命名,提取PDF指定可复制的内容并批量重命名PDF,批量PDF文档指定识别提取区域
本文介绍一款实用工具,能快速从可复制内容的PDF中提取指定区域信息并据此重命名文件。设置提取坐标及导入PDF文档、设定新文件名后启动提取流程,即可高效批量处理。保存坐标设置以便重复使用,适用于需频繁修改大量PDF文件名的场景。
1032 0
[PDF提取重命名]提取识别文字并对PDF文件批量重命名,提取PDF指定可复制的内容并批量重命名PDF,批量PDF文档指定识别提取区域
|
JavaScript Java
Java 将Markdown文件转换为Word和PDF文档
【7月更文挑战第5天】Java中使用`Spire.Doc for Java`库可方便地将Markdown转换为Word或PDF。基本步骤包括导入模块,创建`Document`对象,加载Markdown文件,然后保存为目标格式(`.docx`或`.pdf`)。若遇到`Invalid UTF-8 stream`错误,需确保Markdown文件是UTF-8无BOM编码。页面设置可通过`PageSetup`类调整。注意,实际应用会依据具体需求和环境有所调整。
1570 6