您的位置:首页 > 编程语言 > Java开发

利用pdf2swf将PDF转换成SWF

2016-04-11 08:49 507 查看
将PDF转换成SWF可以使用SWFTools工具中的pdf2swf(http://www.swftools.org/),

CSDN快速免积分下载地址http://download.csdn.net/detail/itmyhome/7270665

一个简单的将PDF文档转成SWF的用法:

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

C:\SWFTools\pdf2swf example.pdf -o example.swf -f -T 9

1、首先下载安装,一直默认下一步即可。

2、java代码

[java] view plain copy 在CODE上查看代码片派生到我的代码片

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:\\SWFTools\\pdf2swf.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();
}
}


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