java操作pdf2swf 转换到其他文件夹
答案:1 悬赏:20 手机版
解决时间 2021-11-27 13:32
- 提问者网友:锁深秋
- 2021-11-26 15:53
java操作pdf2swf 转换到其他文件夹
最佳答案
- 五星知识达人网友:山河有幸埋战骨
- 2021-11-26 16:18
public class Pdf2sfwUtil {
//swf 工具的路径
private static String SWFTools_Windows = "F:/Program Files/swftools/pdf2swf.exe ";
public static void 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())
throw new IOException("aaaaa");
// 调用pdf2swf命令进行转换
String command = SWFTools_Windows +" " + sourcePath+ " -o "
+ destPath + fileName + " -f -T 9";
System.out.println(command);
Process process = Runtime.getRuntime().exec(command);
InputStream stderr = process.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
System.out.println("请忽略:"+line);
int exitVal;
try {
exitVal = process.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String sourcePath = "D:\help.pdf"; //源文件路径
String destPath = "D:\"; //目标路径
String fileName = "help.swf"; //生成文件名
try {
Pdf2sfwUtil.convertPDF2SWF(sourcePath, destPath, fileName);
} catch (Exception e) {
e.printStackTrace();
}
}
}
//swf 工具的路径
private static String SWFTools_Windows = "F:/Program Files/swftools/pdf2swf.exe ";
public static void 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())
throw new IOException("aaaaa");
// 调用pdf2swf命令进行转换
String command = SWFTools_Windows +" " + sourcePath+ " -o "
+ destPath + fileName + " -f -T 9";
System.out.println(command);
Process process = Runtime.getRuntime().exec(command);
InputStream stderr = process.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
System.out.println("请忽略:"+line);
int exitVal;
try {
exitVal = process.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String sourcePath = "D:\help.pdf"; //源文件路径
String destPath = "D:\"; //目标路径
String fileName = "help.swf"; //生成文件名
try {
Pdf2sfwUtil.convertPDF2SWF(sourcePath, destPath, fileName);
} catch (Exception e) {
e.printStackTrace();
}
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯