PDF 转 SWF
发布时间:2020-12-15 18:21:20 所属栏目:百科 来源:网络整理
导读:使用swftools软件工具,将pdf文档转换为swf文档,以便在FlexPaperViewer里使用 import java.io.IOException;import java.io.InputStreamReader;public class StringUtil {public static boolean executeCmdFlash(String cmd) {StringBuffer stdout=new Strin
使用swftools软件工具,将pdf文档转换为swf文档,以便在FlexPaperViewer里使用 import java.io.IOException; import java.io.InputStreamReader; public class StringUtil { public static boolean executeCmdFlash(String cmd) { StringBuffer stdout=new StringBuffer(); try { final Process process = Runtime.getRuntime().exec(cmd); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { process.destroy(); } }); InputStreamReader inputstreamreader = new InputStreamReader(process .getInputStream()); char c = (char) inputstreamreader.read(); if (c != '?') stdout.append(c); while (c != '?') { if (!inputstreamreader.ready()) { System.out.println(stdout); try { process.exitValue(); break; } catch (IllegalThreadStateException _ex) { try { Thread.sleep(100L); } catch (InterruptedException _ex2) { } } } else { c = (char) inputstreamreader.read(); stdout.append(c); } } try { inputstreamreader.close(); } catch (IOException ioexception2) { System.err.println("RunCmd : Error closing InputStream " + ioexception2); return false; } } catch (Throwable e) { e.printStackTrace(); // Globals.Logger("发生错误:" + e,2); return false; } return true; } /** * 取得文件名,去掉后缀 * @param file * @return */ public static String getFileName(String file){ if(file!=null && file.indexOf(".")!=-1){ return file.substring(0,file.indexOf(".")); } return ""; } /** * 转换pdf为swf * @param softPath * @param sourcePath * @param destPath * @param fileName 暂无实际作用,没有用到 * @return */ public static boolean pdf2swf(String softPath,String sourcePath,String destPath,String fileName){ String cmd = softPath + sourcePath + " -o " + destPath + " -T 9"; System.out.println("------开始pdf转换swf:" + sourcePath); if (StringUtil.executeCmdFlash(cmd) == false) { System.out.println("------转换pdf转换swf失败 error;cmd::::::" + cmd); return false; }else{ System.out.println("success;cmd::::::" + cmd); } System.out.println("------结束pdf转换swf:" + sourcePath); return true; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |