谁用过PDF2swf这个工具
答案:1 悬赏:40 手机版
解决时间 2021-11-25 09:00
- 提问者网友:抽煙菂渘情少年
- 2021-11-24 18:55
谁用过PDF2swf这个工具
最佳答案
- 五星知识达人网友:鸠书
- 2021-11-24 19:58
通过代码将PDF转换成SWF来说,现在比较常用的一种方式就是利用SWFTools工具中的pdf2swf 。这个工具还是比较好用的。转换成的SWF文件质量也不错。
public class Converter {
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 = "D:\\Program Files\\SWFTools\\pdf2swf.exe" + " -o \"" + destPath + "\\" + fileName + "\" -s languagedir=D:\\xpdf\\xpdf-chinese-simplified -s flashversion=9 \"" + sourcePath + "\"";
Process pro = Runtime.getRuntime().exec(command);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pro.getInputStream()));
while (bufferedReader.readLine() != null);
try {
pro.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return pro.exitValue();
}
public static void main(String []args) throws IOException {
String sourcePath = "c:\\test.pdf";
String destPath = "c:\\";
String fileName = "test.swf";
Converter.convertPDF2SWF(sourcePath, destPath, fileName);
}
}
public class Converter {
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 = "D:\\Program Files\\SWFTools\\pdf2swf.exe" + " -o \"" + destPath + "\\" + fileName + "\" -s languagedir=D:\\xpdf\\xpdf-chinese-simplified -s flashversion=9 \"" + sourcePath + "\"";
Process pro = Runtime.getRuntime().exec(command);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pro.getInputStream()));
while (bufferedReader.readLine() != null);
try {
pro.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return pro.exitValue();
}
public static void main(String []args) throws IOException {
String sourcePath = "c:\\test.pdf";
String destPath = "c:\\";
String fileName = "test.swf";
Converter.convertPDF2SWF(sourcePath, destPath, fileName);
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯