SWFTools使用说明文档格式.docx
《SWFTools使用说明文档格式.docx》由会员分享,可在线阅读,更多相关《SWFTools使用说明文档格式.docx(16页珍藏版)》请在冰豆网上搜索。
-v,--verboseBeverbose.Usemorethanone-vforgreatereffect.
-z,--zlibUseFlash6(MX)zlibcompression.
-i,--ignoreAllowspdf2swftochangethedraworderofthepdf.Thismaymakethegenerated
-j,--jpegqualityqualitySetqualityofembeddedjpegpicturestoquality.0isworst(small),100isbest(big).(default:
85)
-s,--setparam=valueSetaSWFencoderspecificparameter.Seepdf2swf-shelpformoreinformation.
-w,--samewindowWhenconvertingpdfhyperlinks,don'
tmakethelinksopenanewwindow.
-t,--stopInsertastop()commandineachpage.
-T,--flashversionnumSetFlashVersionintheSWFheadertonum.
-F,--fontdirdirectoryAdddirectorytothefontsearchpath.
-b,--defaultviewerLinkastandardviewertotheswffile.
-l,--defaultloaderLinkastandardpreloadertotheswffilewhichwillbedisplayedwhilethemainswfisloading.
-B,--viewerfilenameLinkviewerfilenametotheswffile.
-L,--preloaderfilenameLinkpreloaderfilenametotheswffile.
-q,--quietSuppressnormalmessages.Use-qqtosuppresswarnings,also.
-S,--shapesDon'
tuseSWFFonts,butstoreeverythingasshape.
-f,--fontsStorefullfontsinSWF.(Don'
treducetousedcharacters).
-G,--flattenRemoveasmanycliplayersfromfileaspossible.
-I,--infoDon'
tdoactualconversion,justdisplayalistofallpagesinthePDF.
-Q,--maxtimenAbortconversionafternseconds.OnlyavailableonUnix.
-sSetaSWFencoderspecific
PDFParameters:
PDFdeviceglobalparameters:
fontdir=<
dir>
adirectorywithadditionalfonts
font=<
filename>
anadditionalfontfilename
pages=<
range>
therangeofpagestoconvert(example:
pages=1-100,210-)
zoom=<
dpi>
theresultion(default:
72)
languagedir=<
Addanxpdflanguagedirectory
multiply=<
times>
Rendereverythingat<
theresolution
poly2bitmapConvertgraphicstobitmaps
bitmapConverteverythingtobitmaps
SWFParameters:
SWFlayeroptions:
jpegsubpixels=<
pixels>
resolutionadjustmentforjpegimages(sameasjpegdpi,butinpixels)
ppmsubpixels=<
pixelsresolutionadjustmentforlosslessimages(sameasppmdpi,butinpixels)
subpixels=<
shortcutforsettingbothjpegsubpixelsandppmsubpixels
drawonlyshapesconverteverythingtoshapes(currentlybroken)
ignoredraworderallowtoperformafewoptimizationsforcreatingsmallerSWFs
linksopennewwindowmakelinksopenanewbrowserwindow
linktargettargetwindownameofnewlinks
linkcolor=<
color)coloroflinks(format:
RRGGBBAA)
linknameurlLinkbuttonswillbenamedliketheURLtheyreferto(handyforiteratingthroughlinkswithactionscript)
storeallcharactersdon'
treducethefontstousedcharactersintheoutputfile
enablezlibswitchonzlibcompression(alsodoneifflashversion>
=6)
bboxvarsstoretheboundingboxoftheSWFfileinactionscriptvariables
dotsTakecaretohandledotscorrectly
reordertags=0/1(default:
1)performsometagoptimizations
internallinkfunction=<
name>
whentheuserclicksainternallink(toadifferentpage)intheconvertedfile,thisactionscriptfunctioniscalled
externallinkfunction=<
whentheuserclicksanexternallink(e.g.http:
//www.foo.bar/)ontheconvertedfile,thisactionscriptfunctioniscalled
disable_polygon_conversionneverconvertstrokestopolygons(willremovecapstylesandjointstyles)
caplinewidth=<
width>
theminimumthichnessalineneedstohavesothatcapstylesbecomevisible(andareconverted)
insertstopputanActionScript"
STOP"
tagineveryframe
protectadda"
protect"
tagtothefile,topreventloadingintheFlasheditor
flashversion=<
version>
theSWFfileversion(6)
framerate=<
fps>
SWFframerate
minlinewidth=<
converthorizontal/verticalboxessmallerthanthiswidthtolines(0.05)
simpleviewerAddnext/previousbuttonstotheSWF
animateinsertashowframetagaftereachplaceobject(animatedraworderofPDFfiles)
jpegquality=<
quality>
setcompressionqualityofjpegimages
splinequality=<
value>
Setthequalityofsplineconvertiontovalue(0-100,default:
100).
disablelinksDisablelinks.
通过代码将PDF转换成SWF来说,现在比较常用的一种方式就是利用SWFTools工具中的pdf2swf(http:
//www.swftools.org/)。
这个工具还是比较好用的。
转换成的SWF文件质量也不错。
/**
Java代码
*PDF转SWF工具
*@authortangs
*
*/
publicclassConverter{
publicstaticintconvertPDF2SWF(StringsourcePath,StringdestPath,
StringfileName)throwsIOException{
//目标路径不存在则建立目标路径
Filedest=newFile(destPath);
if(!
dest.exists())dest.mkdirs();
//源文件不存在则返回
Filesource=newFile(sourcePath);
source.exists())return0;
//调用pdf2swf命令进行转换
Stringcommand="
D:
\\ProgramFiles\\SWFTools\\pdf2swf.exe"
+"
-o\"
"
+destPath+"
\\"
+fileName+"
\"
<
spanstyle="
color:
rgb(255,0,0);
>
-s
languagedir=D:
\\xpdf\\xpdf-chinese-simplified<
/span>
-sflashversion=9\"
+
sourcePath+"
;
Processpro=Runtime.getRuntime().exec(command);
BufferedReaderbufferedReader=newBufferedReader(new
InputStreamReader(pro.getInputStream()));
while(bufferedReader.readLine()!
=null);
try{
pro.waitFor();
}catch(InterruptedExceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
returnpro.exitValue();
publicstaticvoidmain(String[]args)throwsIOException{
StringsourcePath="
c:
\\test.pdf"
StringdestPath="
StringfileName="
test.swf"
Converter.convertPDF2SWF(sourcePath,destPath,fileName);
*PDF转SWF工具
*@authortangs
*
*/
publicclassConverter{
publicstaticintconvertPDF2SWF(StringsourcePath,StringdestPath,StringfileName)throwsIOException{
//目标路径不存在则建立目标路径
Filedest=newFile(destPath);
if(!
//源文件不存在则返回
Filesource=newFile(sourcePath);
//调用pdf2swf命令进行转换
Stringcommand="
-slanguagedir=D:
\\xpdf\\xpdf-chinese-simplified-sflashversion=9\"
+sourcePath+"
Processpro=Runtime.getRuntime().exec(command);
BufferedReaderbufferedReader=newBufferedReader(newInputStreamReader(pro.getInputStream()));
while(bufferedReader.readLine()!
try{
pro.waitFor();
}catch(InterruptedExceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
returnpro.exitValue();
}
publicstaticvoidmain(String[]args)throwsIOException{
StringsourcePath="
StringdestPath="
StringfileName="
Converter.convertPDF2SWF(sourcePath,destPath,fileName);
}
就这么简单的几行代码就可以了。
但是在程序中遇到中文就会出现意想不到的情况,这个也不例外。
在转换中,我发现有些中文PDF文件转换后会出现乱码的现象,因此这里还要处理一下乱码的问题。
看到上面代码中红色的一段了吗?
这就是解决乱码的方法。
这个方法是参考了
1.下载XPDF:
ftp:
//
2.下载字体:
3.修改xpdf-chinese-simplified目录下的add-to-xpdfrc文件。
将里面的路径设为自己的路径:
4.参照上面的代码,在调用pdf2swf命令中加入“-slanguagedir=D:
\\xpdf\\xpdf-chinese-simplified”参数。
这样乱码的问题就解决了。
其中把pdf转成swf的工具就是pdf2swf了。
在命令行中运行pdf2swfsrc.pdfdes.swf一般能满足需求。
而命令行参数可以通过pdf2swf-f得到:
•-h,–helpPrintshorthelpmessageandexit打印帮助信息
•-V,–versionPrintversioninfoandexit打印版本号
•-o,–outputfile.swfDirectoutputtofile.swf.Iffile.swfcontains‘13568621′(file13568630.swf),theneachpage指定输出的swf文件名
•-p,–pagesrangeConvertonlypagesinrangewithrangee.g.1-20
or1,4,6,9-11or
指定转换的页面范围,使用的页码描述方法与打印机打印文件时候的选页一样
•-P,–passwordpasswordUsepasswordfordecipheringthepdf.指定打开pdf的密码
•-v,–verboseBeverbose.Usemorethanone-vforgreatereffect.转换时输出详细的内容
•-z,–zlibUseFlash6(MX)zlibcompression.使用Flash6的zlib压缩机制
•-i,–ignoreAllowspdf2swftochangethedraworderofthepdf.Thismaymakethegenerated允许程序修改pdf的绘制顺序,可能会导致结果与原来有差异
•-j,–jpegqualityqualitySetqualityofembeddedjpegpicturestoquality.0isworst(small),100isbest(big).(default:
85)设置转换其中的jpeg图片的质量,从0到100,默认值是85。
•-s,–setparam=valueSetaSWFencoderspecificparameter.Seepdf2swf-shelpformoreinformation.设置SWF转码时候的参数,具体参数可以用pdf2swf-shelp获取
•-w,–samewindowWhenconvertingpdfhyperlinks,don’tmakethelinksopenanewwindow.设置转换后的swf打开原pdf中的连接时使用相同的窗口
•-t,–stopInsertastop()commandineachpage.在每页结尾添加一个stop()命令
•-T,–flashversionnumSetFlashVersionintheSWFheadertonum.设置SWF所使用的flash版本号
•-F,–fontdirdirectoryAdddirectorytothefontsearchpath.指定字体文件所在路径
•-b,–defaultviewerLinkastandardviewertotheswffile.指定默认的swf导航文件,用来翻页、放大缩小等等
•-l,–defaultloaderLinkastandardpreloadertotheswffilewhichwillbedisplayedwhilethemainswfisloading.指定默认的swf