利用pdf2swf将PDF转换成SWF
将PDF转换成SWF可以使用SWFTools工具中的pdf2swf(http://www.swftools.org/), 一个简单的将PDF文档转成SWF的用法: C:SWFToolspdf2swf example.pdf -o example.swf -f -T 9
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class TestPdf2Swf {
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命令进行转换
String command = "C:SWFToolspdf2swf.exe" + " " + sourcePath+ " -o "
+ destPath + fileName + " -f -T 9";
System.out.println(command);
Process pro = Runtime.getRuntime().exec(command);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(pro.getInputStream()));
while (bufferedReader.readLine() != null);
try {
pro.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
return pro.exitValue();
}
/** * @param args */
public static void main(String[] args) {
String sourcePath = "D:springFramework.pdf"; //源文件路径
String destPath = "D:"; //目标路径
String fileName = "springFramework.swf"; //生成文件名
try {
TestPdf2Swf.convertPDF2SWF(sourcePath,destPath,fileName);
} catch (IOException e) {
e.printStackTrace();
}
}
}
? ?==========分割线============= 有网友反映无法生成swf文件,由于文章时间已经很久了,我又重新下载安装执行了一遍,是没问题的。 对于大家的困扰我也是无能为力啊 ┭┮﹏┭┮,抱歉 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?更新于:2018-06-20 ? 再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |