微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

FlexPager Developer Guide(FlexPager使用指南)

资料列表:

源码下载:http://code.google.com/p/flexpaper/

官方文档:http://flexpaper.devaldi.com/docs.htm

SWF工具下载:http://www.swftools.org/download.html

 

1、将PDF图片等转换成SWF(SWF Tools)

下载http://www.swftools.org/swftools-0.9.1.exe后安装到C:\Program Files\SWFTools

有图形化工具,但考虑到我们要用程序来调用,所以使用命令行。

 

cmd

cd/d C:\Program Files\SWFTools

rem查看帮助

pdf2swf–h

rempdf转swf(整个文件的形式)

pdf2swfe:\MysqL.pdf –o e:\MysqL.swf -T 9 -f

 

图片转换工具:gif2swf,jpeg2swf,png2swf,可用于本项目的图片转swf

具体参数见附录

 

2、使用FlexPager显示SWF

下载http://flexpaper.googlecode.com/files/FlexPaper_1.4.7_flash.zip

解压到任意的地方(最好用Nginx,iis,或tomcat也行发布下,访问地址为http://localhost)

代码我已经给出了,你们测试一下

 

3、如何使用Java执行命令行以实现转换

3.1、思路1:上传时即转换(用户量少,文档少,用户体验好)

3.2、思路2:做成定时任务转换(用户量大,文档大,用户不能马上查看效果

      

       编程要点:如何调用命令行?

       final Process process =Runtime.getRuntime().exec(cmd),核心代码基本上就这一句了,cmd是命令行。

 

4、如何通过编程实现不同平台下的转换

       编程要点:在类Unix(包含Linux)和Widows平台都能跑:

       可以使用apache commons lang3中的

org.apache.commons.lang3.SystemUtils.IS_OS_UNIX

org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS

来判断不同的平台。

 

 

附录A

       加 “-T 9” 参数,设置输出版本为flash9,解决PDF文件只有一页,生成的swf不能播放的问题。(网上找的未验证,具体参数见附录B)

       注意-T 10 不行的,有问题,这个我试过,可以下最新trunk上的pdf2swf试试。

       有时会出现转换错误,不要管,尽量用命令行。

      

 

附录B:pdf2swf参数参考(pdf2swf  -h 查看)

-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 ‘13568621′ (file13568630.swf),then each page指定输出的swf文件

-p,–pages range Convert only pages in range with range e.g. 1-20

or1,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.使用Flash6的zlib压缩机制

-i,–ignore Allows pdf2swf to change the draw order of the pdf. This maymake the generated允许程序修改pdf的绘制顺序,可能会导致结果与原来有差异

-j,–jpegquality quality Set quality of embedded jpeg pictures toquality. 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 -shelp 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 willbe 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 storeeverything as shape. 不使用字体,所有都转为形状。

-f,–fonts Store full fonts in SWF. (Don’t reduceto used characters). 在swf中保存全部字体。

-G,–flatten Remove as many clip layers from file as possible. 在文件中尽量去除影片层,合并它们

-I,–info Don’t do actual conversion,justdisplay a list of all pages in the PDF. 不做实际转换,仅显示PDF的信息。

-Q,–maxtime n Abort conversion after n seconds. Only available on Unix. 如果运行时间超时则退出

 

附录C :SystemUtils参考

org.apache.commons.lang3.SystemUtils参考

IS_OS_UNIX

 

publicstatic final boolean IS_OS_UNIX

Istrue if this is a UNIX like system,as in any of AIX,HP-UX,Irix,Linux,MacOSX,Solaris or SUN OS.

 

Thefield will return false if OS_NAME is null.

 

Since:

2.1

IS_OS_WINDOWS

 

publicstatic final boolean IS_OS_WINDOWS

Istrue if this is Windows.

 

Thefield will return false if OS_NAME is null.

 

Since:

2.0

 

附录D:官方文档参考

1、 使用简介

http://flexpaper.devaldi.com/docs.jsp

 

2、ConvertingDocuments,注意那几个参数

http://flexpaper.devaldi.com/docs_converting.jsp

 

3、LargeDocuments,大文件如何转换

http://flexpaper.devaldi.com/docs_largedocs.jsp

 

4、完整参数参考,最全最新的最权威的

http://flexpaper.devaldi.com/docs_parameters.jsp

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐