flex开发的仿pdf阅读器(swftools将PDF转成swf)
- 格式:doc
- 大小:52.50 KB
- 文档页数:7
SWFTools 是一组用来处理 Flash 的 swf 文件的工具包,包括:1. 合并工具 swfcombine2. 抽取工具 swfextract3. PDF/JPEG/PNG/AVI/TTF/WAV 到 SWF 的转换工具:pdf2swf, jpeg2swf, png2swf, avi2swf, font2swf, and wav2swf|4. 文本解析工具 swfstrings5. SWF 解析器 swfdump6. SWF 读写库 rfxswflib一个简单的将PDF文档转成SWF的用法:C:\SWFTools\pdf2swf Paper3.pdf -o Paper3.swf -f -T 9pdf2swf man pagepdf2swf -s parametersCurrent GitUsage: /usr/local/swft_git/bin/pdf2swf [-options] file.pdf -o file.swf-h , --help Print short help message and exit-V , --version Print version info and exit-o , --output file.swf Direct output to file.swf. If file.swf contains '%' (file%.swf), then each page goes to a seperate file.-p , --pages range Convert only pages in range with range e.g. 1-20 or 1,4,6,9-11 or-P , --password password Use password for deciphering the pdf.-v , --verbose Be verbose. Use more than one -v for greater effect. -z , --zlib Use Flash 6 (MX) zlib compression.-i , --ignore Allows pdf2swf to change the draw order of the pdf. This may make the generated-j , --jpegquality quality Set quality of embedded jpeg pictures to quality.0 is worst (small), 100 is best (big). (default:85)-s , --set param=value Set a SWF encoder specific parameter. See pdf2swf -s help for more information.-w , --samewindow When converting pdf hyperlinks, don't make the links open a new window.-t , --stop Insert a stop() command in each page.-T , --flashversion num Set Flash Version in the SWF header to num.-F , --fontdir directory Add directory to the font search path.-b , --defaultviewer Link a standard viewer to the swf file.-l , --defaultloader Link a standard preloader to the swf file which will be displayed while the main swf is loading.-B , --viewer filename Link viewer filename to the swf file.-L , --preloader filename Link preloader filename to the swf file.-q , --quiet Suppress normal messages. Use -qq to suppress warnings, also.-S , --shapes Don't use SWF Fonts, but store everything as shape. -f , --fonts Store full fonts in SWF. (Don't reduce to used characters).-G , --flatten Remove as many clip layers from file as possible. -I , --info Don't do actual conversion, just display a list of all pages in the PDF.-Q , --maxtime n Abort conversion after n seconds. Only available on Unix.-s Set a SWF encoder specificPDF Parameters:PDF device global parameters:fontdir=<dir> a directory with additional fontsfont=<filename> an additional font filenamepages=<range> the range of pages to convert (example: pages=1-100,210-) zoom=<dpi> the resultion (default: 72)languagedir=<dir> Add an xpdf language directorymultiply=<times> Render everything at <times> the resolutionpoly2bitmap Convert graphics to bitmapsbitmap Convert everything to bitmapsSWF Parameters:SWF layer options:jpegsubpixels=<pixels> resolution adjustment for jpeg images (same as jpegdpi, but in pixels)ppmsubpixels=<pixels resolution adjustment for lossless images (same as ppmdpi, but in pixels)subpixels=<pixels> shortcut for setting both jpegsubpixels and ppmsubpixelsdrawonlyshapes convert everything to shapes (currently broken) ignoredraworder allow to perform a few optimizations for creating smaller SWFslinksopennewwindow make links open a new browser windowlinktarget target window name of new linkslinkcolor=<color) color of links (format: RRGGBBAA)linknameurl Link buttons will be named like the URL they refer to (handy foriterating through links with actionscript)storeallcharacters don't reduce the fonts to used characters in the output fileenablezlib switch on zlib compression (also done if flashversion>=6)bboxvars store the bounding box of the SWF file in actionscript variablesdots Take care to handle dots correctlyreordertags=0/1 (default: 1) perform some tag optimizations internallinkfunction=<name> when the user clicks a internal link (to a different page) in the converted file, this actionscript function is calledexternallinkfunction=<name> when the user clicks an external link (e.g. http://www.foo.bar/) on the converted file, this actionscript function is called disable_polygon_conversion never convert strokes to polygons (will remove capstyles and joint styles)caplinewidth=<width> the minimum thichness a line needs to have so that capstyles become visible (and are converted)insertstop put an ActionScript "STOP" tag in every frame protect add a "protect" tag to the file, to prevent loading in the Flash editorflashversion=<version> the SWF fileversion (6)framerate=<fps> SWF framerateminlinewidth=<width> convert horizontal/vertical boxes smaller than this width to lines (0.05)simpleviewer Add next/previous buttons to the SWFanimate insert a showframe tag after each placeobject (animate draw order of PDF files)jpegquality=<quality> set compression quality of jpeg imagessplinequality=<value> Set the quality of spline convertion to value (0-100, default: 100).disablelinks Disable links.通过代码将PDF转换成SWF来说,现在比较常用的一种方式就是利用SWFTools工具中的pdf2swf(/)。
一、准备转换工具1.SWFTools (有windows系统的和 linux 系统的)2.xpdf (有windows系统的和 linux 系统的 )作用:主要解决中文乱码问题3.准备 FlexPaper_1.2.4_flash(网上直接下载里面含有 js插件 jsp页面下面会展示)FlexPaper( FlexPaper_1.2.4_flash 重命名来的)这个包必须放到 webapps 下面 jsp页面里面才能取得到文件二、1、上传的pdf文件到本地(windows 和 linux 都行)2、pdf 转成 swf (两种我都试过了,都成功了!)/*** @author张志广* QQ:691554407* pdf格式文件转化为swf格式插件* 插件要求:必须安装SWFTools工具* windows:D:\\SWFTools\\pdf2swf.exe 可以根据自己的路径进行修改* filePath = pdf文件上传路径(不含文件名);* fileName = "test.pdf";*/publicclass Convert {publicstaticvoid convertPDF2SWF(String filePath, StringfileName ,HttpServletRequest request) throws IOException { //使用pdf2swf转换命令//filePath = "C:" + filePath;String RealPath =request.getSession().getServletContext().getRealPath("/");RealPath = RealPath.substring(0,RealPath.length()-1);//System.out.println("-----------------RealPath="+ RealPath);File uploadFile = new File(RealPath + filePath); //指定上传文件的位置if(!uploadFile.exists() || uploadFile == null) { //判断指定路径dir是否存在,不存在则创建路径uploadFile.mkdirs();}String exepath_windows = "D:/SWFTools/pdf2swf.exe";String exePath_linux ="SWFTools/pdf2swf.exe";Process pro = null;String swffile_name =fileName.substring(0,fileName.indexOf("."))+".swf";if(isWindowsSystem()){//如果是windows系统String command= exepath_windows + " -t \""+filePath+"\\"+ fileName +"\" -o \""+RealPath + filePath+"\\"+ swffile_name +"\" -slanguagedir=D:\\xpdf\\xpdf-chinese-simplified -s flashversion=9 ";// System.out.println("command="+command);//执行cmd命令pro = Runtime.getRuntime().exec("cmd /c "+command);}else{//如果是linux系统,路径不能有空格,而且一定不能用双引号,否则无法创建进程/* String[] cmd = new String[2];cmd[0] = "/usr/local/bin/pdf2swf";cmd[1] = "-o "+RealPath + filePath+"/"+ swffile_name +" -T -z -t "+ languagedir=/usr/share/xpdf/xpdf-chinese-simplified -sflashversion=9";*/String command = "/usr/local/bin/pdf2swf -o "+ RealPath + filePath+"/"+ swffile_name +" -T -z -t "+ filePath+"/"+ fileName + " -s languagedir=/usr/share/xpdf/xpdf-chinese-simplified -s flashversion=9";//RealPath + filePath+"/"+ swffile_name必须转到webapps项目程下面去才能够在页面取得到// String cmd[]={"/bin/csh",null,command};////Runtime执行后返回创建的进程对象pro = Runtime.getRuntime().exec(command);}//非要读取一遍cmd的输出,要不不会flush生成文件(多线程)new DoOutput(pro.getInputStream()).start();new DoOutput(pro.getErrorStream()).start();try {//调用waitFor方法,是为了阻塞当前进程,直到cmd执行完pro.waitFor();} catch (InterruptedException e) {e.printStackTrace();}}/*** 判断是否是windows操作系统* @author iori* @return*/privatestaticboolean isWindowsSystem() {String p = System.getProperty("");return p.toLowerCase().indexOf("windows") >= 0 ? true :false;}/*** 多线程内部类* 读取转换时cmd进程的标准输出流和错误输出流,这样做是因为如果不读取流,进程将死锁* @author iori*/privatestaticclass DoOutput extends Thread {public InputStream is;// 构造方法public DoOutput(InputStream is) {this.is = is;publicvoid run() {BufferedReaderbr = new BufferedReader(new InputStreamReader(this.is));String str = null;try {// 这里并没有对流的内容进行处理,只是读了一遍while ((str = br.readLine()) != null);} catch (IOException e) {e.printStackTrace();} finally {if (br != null) {try {br.close();} catch (IOException e) {e.printStackTrace();}}}}}Action 中1、你可以在上传pdf文件后调用Convert进行转换//filePath:\file\db_file\2011413//fileName: iBATIS-SqlMaps.pdfString swf_name =fileName.substring(0,fileName.indexOf("."))+".swf";String real_swf_name = filePath + "/" + swf_name;request.setAttribute("real_swf_name", real_swf_name);----jsp页面<%@page language="java"contentType="text/html;charset=UTF-8"%><%@include file="../com/sessionCheck.jsp"%><%String context = request.getContextPath(); %><!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.d td"><!-- saved from url=(0014)about:internet --><html xmlns="/1999/xhtml"lang="en"xml:lang="en"><head><title></title><meta http-equiv="Content-Type"content="text/html; charset=utf-8"/><style type="text/css"media="screen">html,body{ height:100%; }body { margin:0; padding:0; overflow:auto; }#flashContent{ display:none; }</style><script type="text/javascript"src="js/swfobject/swfobject.js"></scrip t><script type="text/javascript">if(window.addEventListener)window.addEventListener('DOMMouseScroll', handleWheel, false);window.onmousewheel = document.onmousewheel = handleWheel;if (window.attachEvent)window.attachEvent("onmousewheel", handleWheel);function handleWheel(event){try{if(!window.document.FlexPaperViewer.hasFocus()){returntrue;}window.document.FlexPaperViewer.setViewerFocus(true);window.document.FlexPaperViewer.focus();if(navigator.appName == "Netscape"){if (event.detail)delta = 0;if (event.preventDefault){event.preventDefault();event.returnValue = false;}}returnfalse;}catch(err){returntrue;}}</script><script type="text/javascript"><!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->var swfVersionStr = "9.0.124";<!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->var xiSwfUrlStr = "${expressInstallSwf}";var flashvars = {SwfFile : escape("<%=context%>${real_swf_name}"), //工程名/你的swf真实路径(必须得在webapps下面)Scale : 0.6,ZoomTransition :"easeOut",ZoomTime : 0.5,ZoomInterval : 0.1,FitPageOnLoad :false,FitWidthOnLoad :true,PrintEnabled :true,FullScreenAsMaxWindow :false,localeChain: "en_US"};var params = {}params.quality = "high";params.bgcolor = "#ffffff";params.allowscriptaccess = "sameDomain";params.allowfullscreen = "true";var attributes = {};attributes.id = "FlexPaperViewer"; = "FlexPaperViewer";swfobject.embedSWF("/FlexPaper/FlexPaperViewer.swf", "flashContent", // 同样在webapps目录下,可以自己调"900", "600",swfVersionStr, xiSwfUrlStr,flashvars, params, attributes);swfobject.createCSS("#flashContent","display:block;text-align:center;");</script></head><body><div style="position:absolute;left:10px;top:10px;"><div id="flashContent"><p>需要安装flash 10 及以上版本才可以浏览。
flexpaper_flash使用说明1.FlexPaper简介FlexPaper是一个开源轻量级的文档浏览组件,被设计和比如PDF2SWF库(包含于SWFTools)一起工作,使得在网页上,Adobe Flex以及别的基于Flash的应用程序中显示和交互PDF文件成为可能。
即,使得在没有安装PDF阅读器软件的情况下浏览PDF文件成为可能。
FlexPaper 项目同时提供了Flex库和独立的Flash版本。
2.使用FlexPaper2.1下载FlexPaperFlexPaper在google code上的项目地址为/p/flexpaper/。
目前,FlexPaper 最新的flash版本为FlexPaper_1.5.1_flash.zip。
下载、解压后,可以看到如图6-1显示的目录:主要文件,文件夹说明:examples文件夹:存放FlexPaper使用的例子js文件夹:存放FlexPaper调用的js文件php文件夹:存放php使用FlexPaper的例子index.html:例子主页FlexPaperViewer.swf:FlexPaper的核心文件playerProductInstall.swf:如果客户端浏览器的flashplayer版本过低,将嵌入此swf文件2.2FlexPaper参数说明SwfFile(String):需要使用FlexPaper打开的文档Scale(Number):初始化缩放比例,参数值应该是大于零的整数(1=100%)ZoomTransition(String):FlexPaper中缩放样式,它使用和Tweener一样的样式,默认参数值为easeOut,其他可选值包括:easenone,easeout,linear,easeoutquadZoomTime(Number):从一个缩放比例变为另外一个缩放比例需要花费的时间,该参数值应该为0或更大ZoomInterval(Number):缩放比例之间间隔,默认值为0.1,该值应该为正数FitPageOnLoad(Boolean):初始化时自适应页面,与使用工具栏上的适应页面按钮同样的效果FitWidthOnLoad(Boolean):初始化时自适应页面宽度,与工具栏上的适应宽度按钮同样的效果localeChain(String):设置地区(语言),目前支持一下语言:en_US (English);fr_FR (French);zh_CN (Chinese,Simple);es_ES (Spanish);pt_BR (Brazilian Portugese);ru_RU (Russian);fi_FN (FInnish);de_DE (German);nl_NL (Netherlands);tr_TR (Turkish);se_SE (Swedish);pt_PT (Portugese);el_EL (Greek);da_DN (Danish);cz_CS (Czech);it_IT (Italian);pl_PL (Polish);pv_FN (Finish);hu_HU (Hungarian)。
Java FlexPaper swfTools_仿百度文库文档在线预览系统设计与实现最近在给客户开发文档管理系统时,客户要求上传到管理系统的文档(包括ppt,word,excel,txt)只能预览不允许下载。
想到了百度文库和豆丁网,百度文库和豆丁网的在线预览都是利用flash来播放文档的,在网上查阅了大量资料,终于实现了该项功能,现将自己的设计和实现整理如下,自己可以试试。
一、如何将文档转成flash支持的swf文件实现在线播放?1.先用openOffice把ppt、word、excel、txt类型的文档转换成pdf2.用swftools将pdf转换成swf,然后利用FlexPaper插件实现在线播放预览。
二、具体实现1.安装必备工具组件(1)安装openoffice,openoffice是开源免费的文字处理软件,它可以将office文档转成pdf文件(笔者安装到D:\Program Files),openOffice下载地址/download/index.html(2)安装完openoffice后必须启动其server,以命令行方式启动openoffice server。
进入cmd命令行提示符D:\Program Files\ 3\program\键入如下命令:soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;"–nofirststartwizard进入windows任务管理器查看有个进程soffice.bin,说明openoffice启动成功!(3)安装swfTools(安装到D:\Program Files)swftools作用是将pdf转换为swf文件以便flexpaper播放。
下载地址:/download.html(4)下载flexpaper,下载地址:/download/笔者下载的是FlexPaper_1.5.1,下载后将其解压备用。
一个可以把pdf转换swf的转换器,因为有时候需要pdf转换成swf来拿到别的地方用。
或者要把pdf转换成word、excel、HTML等文件格式时就需要到pdf转swf格式转换器啦。
一个万能的pdf格式转换器下载。
特别是一些工作人员,有时上头发下来的文件是pdf的要编辑的话需要转换word会比较方便哦。
无论你是转换那个pdf转swf格式转换器都可以的。
打开,pdf转换器后选择最下面的pdf转swf格式转换器。
这个就是用来把pdf转换成swf转换器了。
还有其他几个转换器大家需要的也可以直接打开用。
用法也是和,pdf转swf格式转换器差不多的。
然后把文件添加到pdf转swf格式转换器里面去,你可以点击左上角的绿色加号添加文件,也可以选择加号旁边的文件夹图标添加文件夹里面的全部pdf文件。
pdf 转swf格式转换器是可以批量转换的。
如果你文件不多也可以直接拖文件到pdf转swf格式转换器里面的空白区。
在pdf转swf格式转换器的左边你可以设置一下转换时的参数,比如说转换的开始页和结束页,或者全部转换。
还有是不是要添加播放按钮,FPS值是多少。
这些参数你都可以在设置里面一一选择。
选择好了后就点开始转换。
文件多的话就要久一点,个把文件pdf转swf格式转换器基本上是一两分钟就可以搞定。
Flexpaper 开发教程1. Flexpaper介绍1.1 Flexpaper是什么?Flexpaper 是由一家新西兰的 Devaldi 公司开发的在线浏览各 种文件的组件,它采用的是 GPL开源的协议,即源代码开放 并可以最其进行修改使用,这一切都是免费得,但不能对 Flexpaper 源码修改后封装成商业软件进行发布和销售。
Flexpaper 官方主页:1.2 Flexpaper可以做什么?如果你有一些DOC、PPT、PDF等格式的文档,想在网站里提供给大家在线阅读,那怎样做好呢?现在 Flexpaper 可以为你做到,当然 Flexpaper 还有一个搭档,那就是 SWFTools,通过 SWFTools 生产SWF,再通过Flexpaper组件显示,这对黄金搭档可以为你实现的在线文档功能。
使用Flexpaper浏览PDF,那需要PDF软件环境的支持吗?答案是不需要的,Flexpaper还可以被 当做 Flex 的库来使用,这些都使开发、使用变得更简单。
1.3 Flexpaper版本Flexpaper的初始版本1.0发布于2009年, 到现在已经有42个版本。
swc版本为组件包, 使用swc 组件包需要导入到工程中再调用,flash 版本为可以单独执行的,里面有例子、JS 文件、SWF 文 件,我们采用flash版本很容易就可以使用Flexpaper显示在线文档。
SWFTools介绍1.5 SWFTools介绍SWFTools是一个SWF处理、转换的开源工具,它的功能主要体现在:1. SWF的抽取、合并、解析、读写;2. PDF/JPEG/PNG/AVI/TTF/WAV等格式转换成SWF。
SWFTools是采用GPL开源协议,永久免费,现在SWFTools已经支持 Solaris, Linux (32 bit 和 64 bit), FreeBSD, OpenBSD, HPUX, Solaris, MacOS X and Windows 98/ME/2000/XP/Vista等多个系 统。
pdf转swf最简单方式
要将PDF文件转换为SWF文件(即Adobe Flash格式),可以使用一些工具和库来实现。
以下是其中一种简单的方式:
1. 使用SWFTools:SWFTools是一个开源的软件套件,提供了一些命令行工具来处理SWF文件。
2. 安装完SWFTools后,打开命令行终端或命令提示符。
3. 使用以下命令将PDF转换为SWF:
```
pdf2swf input.pdf -o output.swf -T 9
```
其中,input.pdf是要转换的PDF文件的路径,output.swf是生成的SWF文件的路径,-T 9用于指定转换质量,9表示最高质量。
4. 运行命令后,SWFTools将开始转换过程,并生成一个SWF文件。
请注意,SWF是一种已经逐渐被淘汰的技术,由于安全和性能方面的考虑,许多现代浏览器已停止对SWF的支持。
因此,在将PDF转换为SWF之前,建议您考虑是否有其他更适合的格式来呈现内容,例如HTML5或其他支持的文档格式。
Java基于springmvc实现⽂档预览(openoffice+swftools+fle。
Java基于springmvc实现⽂档预览(openoffice+swftools+flexpaper)(排坑记录)本⽂代码来源已在末尾标注,写本⽂的⽬的在于记录⾃⼰在实践过程中遇到的问题及解决⽅案需求实现⽂档在线预览原理1.通过第三⽅⼯具openoffice,将word、excel、ppt、txt等⽂件转换为pdf⽂件2.通过swfTools将pdf⽂件转换成swf格式的⽂件3.通过FlexPaper⽂档组件在页⾯上进⾏展⽰安装包下载1.openoffice是Apache下的⼀个开放免费的⽂字处理软件下载地址:Apache Open Office 4.x2.SWFTools是⼀组⽤来处理Flash的swf⽂件的⼯具包,我们使⽤它将pdf⽂件转成swf⽂件!下载地址:SWFTools官⽹下载 swftools-2013-04-09-1007.exe3.FlexPaper是⼀个开源轻量级的在浏览器上显⽰各种⽂档的组件下载地址:FlexPaper官⽹下载⼯具安装安装过程中,出现了点问题,我习惯将软件装在D:\Program Files (x86)或者D:\Program Files下,结果就是在这⾥出了问题安装openoffice,安装路径⾃定义,没有问题,安装完成后需要将服务打开,从cmd进⼊到openoffice 的安装盘符,⽤下⾯的命令启动服务soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard安装swftools,第⼀安装路径:D:\Program Files (x86)\SWFTools,安装完成,项⽬中有个swftools的路径,更改成安装路径,如下结果运⾏项⽬时,报错如下,说找不到这个⽂件断点调试后发现,程序中⽤到了swftools的安装路径,⽽路径中带有空格,按照空格符拆分字符串后,得到的路径时“D:\Program”,⽽不是”D:\Program Files (x86)\SWFTools”,于是问题转化为了怎么去去掉空格,避免这⾥拆分字符串后分离这个路径两种解决⽅案1、⽤另外的⽅法表⽰这个路径,使路径中不带有空格,这种想法⼜有两种实现,⼀种是缩写,另⼀种是镜像,亲⾃试验了⼀下两种都失败了,但是这⾥还是列出来,毕竟涨了⼀下姿势⽤缩写。
使用FlexPaper实现office文件的预览(C#版)需求很简单,用户上传office文件(word、excel、ppt)后,可以预览上传的这些文件。
搜索的相关的资料后。
整理如下:Step1.用户上传office文件。
Step2.把Office文件转化为pdf文件Step3.把pdf文件转化为swf文件Step4.使用flexpaper插件预览swf文件根据这四步,我们逐步分析:Step1.上传文件,在此不做赘述。
Step2.把Office文件转化为pdf文件。
必须保证你的office版本在2007之上。
我第一次使用office2003,不报错,但是也没用生成相关的pdf文件。
果断使用了最新的office2013即可完美运行。
在次贴出将word转化为pdf文件的代码,完整实例,请看附件。
///<summary>///把Word文件转换成为PDF格式文件///</summary>///<param name="sourcePath">源文件路径</param>///<param name="targetPath">目标文件路径</param>///<returns>true=转换成功</returns>public static bool WordToPDF(string sourcePath, string targetPath){bool result = false;Microsoft.Office.Interop.Word.WdExportFormat exportFormat = Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;Microsoft.Office.Interop.Word.ApplicationClassapplication = null;Microsoft.Office.Interop.Word.Document document = null;try{application = newMicrosoft.Office.Interop.Word.ApplicationClass();application.Visible = false;document = application.Documents.Open(sourcePath); document.SaveAs();document.ExportAsFixedFormat(targetPath, exportFormat);result = true;}catch (Exception e){Console.WriteLine(e.Message);result = false;}finally{if (document != null){document.Close();document = null;}if (application != null){application.Quit();application = null;}GC.Collect();GC.WaitForPendingFinalizers();GC.Collect();GC.WaitForPendingFinalizers();}return result;}(考虑到有些和我一样的新手,在此赘述几句吧:如果你使用vs2010开发,在添加office 引用的时候,直接选择.net栏目下的office、Microsoft.Office.Interop.Word,Microsoft.Office.Interop.PowerPoint和Microsoft.Office.Interop.Excel,并且保证office的版本高于后三者就行啦。
flex开发的仿pdf阅读器(swftools将PDF转成swf)SWFTools 是一组用来处理 Flash 的 swf 文件的工具包,包括:1. 合并工具 swfcombine2. 抽取工具 swfextract3. PDF/JPEG/PNG/AVI/TTF/WAV 到 SWF 的转换工具:pdf2swf, jpeg2swf, png2swf,avi2swf, font2swf, and wav2swf|4. 文本解析工具 swfstrings5. SWF 解析器 swfdump6. SWF 读写库 rfxswflibSWFTools提供了一系列将各种文件转成swf的工具:∙font2swf.exe∙gif2swf.exe∙jpeg2swf.exe∙pdf2swf.exe∙png2swf.exe∙wav2swf.exe具体的功能就顾名思义了。
其中把pdf转成swf的工具就是pdf2swf了。
在命令行中运行pdf2swf src.pdf des.swf一般能满足需求。
而命令行参数可以通过pdf2swf -f得到:∙-h , –help Print short help message and exit 打印帮助信息∙-V , –version Print version info andexit 打印版本号∙-o , –output file.swf Direct output to file.swf. If file.swf contains ‘13568621′ (file13568630.swf), then each page指定输出的swf文件名∙-p , –pages range Convert only pages in range with range e.g.1-20or 1,4,6,9-11 or指定转换的页面范围,使用的页码描述方法与打印机打印文件时候的选页一样∙-P , –password password Use password for deciphering the pdf.指定打开pdf的密码∙-v , –verbose Be verbose. Use more than one -v for greater effect.转换时输出详细的内容∙-z , –zlib Use Flash 6 (MX) zlib compression.使用Flash 6的zlib压缩机制∙-i , –ignore Allows pdf2swf to change the draw order of the pdf. This may make the generated允许程序修改pdf的绘制顺序,可能会导致结果与原来有差异∙-j , –jpegquality quality Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)设置转换其中的jpeg图片的质量,从0到100,默认值是85。
∙-s , –set param=value Set a SWF encoder specific parameter. See pdf2swf -s help for more information. 设置SWF转码时候的参数,具体参数可以用pdf2swf -s help获取∙-w , –samewindow When converting pdf hyperlinks, don’t make the links open a new window. 设置转换后的swf打开原pdf中的连接时使用相同的窗口∙-t , –stop Insert a stop() command in each page. 在每页结尾添加一个stop()命令∙-T , –flashversion num Set Flash Version in the SWF header to num. 设置SWF所使用的flash版本号∙-F , –fontdir directory Add directory to the font search path. 指定字体文件所在路径∙-b , –defaultviewer Link a standard viewer to the swf file. 指定默认的swf导航文件,用来翻页、放大缩小等等∙-l , –defaultloader Link a standard preloader to the swf file which will be displayed while the main swf is loading. 指定默认的swf 加载文件,用来显示加载进程效果∙-B , –viewer filename Link viewer filename to the swf file. 指定swf导航文件,作用同-b∙-L , –preloader filename Link preloader filename to the swf file. 指定swf加载文件,作用同-l∙-q , –quiet Suppress normal messages. Use -qq to suppress warnings, also. 不打印普通信息,用-qq就不打印警告信息。
∙-S , –shapes Don’t use SWF Fonts, but store everything as shape. 不使用字体,所有都转为形状。
∙-f , –fonts St ore full fonts in SWF. (Don’t reduce to used characters). 在swf中保存全部字体。
∙-G , –flatten Remove as many clip layers from file as possible. 在文件中尽量去除影片层,合并它们∙-I , –info Don’t do actual conversion, just display a list of all pages in the PDF. 不做实际转换,仅显示PDF的信息。
∙-Q , –maxtime n Abort conversion after n seconds. Only available on Unix. 如果运行时间超时则退出。
然后看看-s都可以设置些什么:PDF Parameters:PDF device global parameters:fontdir= a directory with additional fonts 指定字体目录, 与1级参数的-F相若font= an additional font filename 增加额外的字体文件pages= the range of pages to convert (example: pages=1-100,210-) 指定页面范围,与1级参数的-p相若zoom= the resolution (default: 72) 指定分辨率,默认为72dpilanguagedir= Add an xpdf language directory 增加一个xpdf的语言目录,对非西欧字符有用multiply= Render everything at the resolution 在几倍分辨率下渲染poly2bitmap Convert graphics to bitmaps 把其中的图形转成点阵bitmap Convert everything to bitmaps 把所有内容转成点阵(包括字体)SWF Parameters:SWF layer options:jpegsubpixels=<pixels> resolution adjustment for jpeg images (same as jpegdpi, but in pixels) jpeg图片的分辨率ppmsubpixels=<pixels> resolution adjustment for lossless images (same asppmdpi, but in pixels) 无损图片的分辨率subpixels=<pixels> shortcut for setting both jpegsubpixels and ppmsubpixels 快速设置上两个参数drawonlyshapes convert everything to shapes (currently broken) 所有都转成图形ignoredraworder allow to perform a few optimizations for creating smaller SWFs 允许执行一些小优化linksopennewwindow make links open a new browser window 链接打开新窗口linktarget target window name of new links 新链接窗口的名称linkcolor=<color) color of links (format: RRGGBBAA) 链接的颜色linknameurl Link buttons will be named like the URL they refer to (handy for iterating through links with actionscript) 链接名称与链接URL一致storeallcharacters don’t reduce the fonts to used characters in the output file 保存所有的字符字体enablezlib switch on zlib compression (also done if flashversion>=7) 使用zlib压缩bboxvars store the bounding box of the SWF file in actionscript variables 在as中保存swf的区域大小dots Take care to handle dots correctly 保存单点显示reordertags=0/1 (default: 1) perform some tag optimizations 执行某些tag优化internallinkfunction=<name> when the user clicks a internal link (to a different page) in the converted file, this actionscript function is called 内部链接函数,如果点击一个内部链接,将调用该actionscript函数externallinkfunction=<name> when the user clicks an external link (e.g.有些pdf中的图形转换效果不好,会产生过多shape,这种情况下可以使用 -s poly2bitmap 的参数,将图形转成点阵。