在使用pdf2swf.exe工具把pdf转换swf时,怎么在swf头部添加json数据
答案:1 悬赏:40 手机版
解决时间 2021-11-12 07:42
- 提问者网友:富士山上尢
- 2021-11-11 14:35
在使用pdf2swf.exe工具把pdf转换swf时,怎么在swf头部添加json数据
最佳答案
- 五星知识达人网友:时间的尘埃
- 2021-11-11 16:13
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();
}
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯