- import java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Pdf2SwfConvert {
- public static int convertPDF2SWF(String sourcePath, String destPath, String fileName) throws IOException {
- //目标路径不存在则建立目标路径
- File dest = new File(destPath);
- if (!dest.exists()) dest.mkdirs();
- System.out.println("------------tw-----");
- //源文件不存在则返回
- File source = new File(sourcePath);
- System.out.println("------=----tw---2");
- if (!source.exists()) return 0;
- System.out.println("------=----tw---3");
- //调用pdf2swf命令进行转换
- String command = "D:\\a\\SWFTools\\pdf2swf.exe"+" -o \""+destPath+"\\"+fileName+"\" -s languagedir=D:\\xpdf\\chinese-simplified -s flashversion=9 \""+sourcePath+"\"";
- System.out.println("------=----tw---\n"+command);
- Process pro = Runtime.getRuntime().exec(command);
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pro.getInputStream()));
- while (bufferedReader.readLine() != null);
- System.out.println("--2-");
- try {
- pro.waitFor();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.out.println("---------tw----------");
- return pro.exitValue();
- }
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
- String sourcePath = "d:\\1\\XMPPRFC3920.PDF";
- String destPath = "d:\\2";
- String fileName = "XMPPRFC3920.swf";
- Pdf2SwfConvert.convertPDF2SWF(sourcePath, destPath, fileName);
- }
- }