嗯嗯, 问题我已经解决了,是命令行的问题之前的我命令行是:"D:/Program Files/SWFTools/pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9" ,现在改为了:
"D:/Program Files/SWFTools/pdf2swf.exe" + " -o " + destPath + "/" + fileName + " -s flashversion=9 " + sourcePath + "",我把该方法的代码发来看看吧,希望大家能用的着
:
/** * * @param sourcePath 源pdf文件
* @param destPath 目标路径
* @param fileName swf文件名如:542315.swf
* @return
* @throws IOException
*/
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 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) {
e.printStackTrace();
}
return pro.exitValue();
}
|