您的位置:首页 > 其它

把pdf文档转化为swf

2012-05-15 10:43 232 查看
1.下载swftools,并安装在自己的电脑上。我这里把swftools安装在C盘(C:\SWFTools)。

2.使用命令行把pdf文档转换为swf文件,C:\SWFTools\pdf2swf -t
sourcePath -o
destFileName -s flashversion=9

写命令的时候要特别注意flash的版本问题,默认转换出来的是flash8版本。

也可以用代码来实现(摘自网上,未验证):

</pre><pre class="java" name="code">package bao1;

import java.io.*;

public class Converter extends java.lang.Thread{

public static int convertPDF2SWF(String sourcePath, String destPath, String fileName) throws IOException {

//目标路径不存在则建立目标路径

File dest = new File(destPath);

if (!dest.exists()) dest.mkdirs();

//源文件不存在则返回

File source = new File(sourcePath);

if (!source.exists()) return 0;

//调用pdf2swf命令进行转换

//调用pdf2swf命令进行转换

String command= "G:\\SWFTools\\pdf2swf"+" -t "+sourcePath+" -o "+destPath+fileName+" -s flashversion=9 ";

Process pro = Runtime.getRuntime().exec(command);

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pro.getInputStream()));

while (bufferedReader.readLine() != null);

try {

pro.waitFor();

// pro2.waitFor();

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return pro.exitValue();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: