java 调用命令行写法以svg(xml字符串)通过inkscape转化为pdf,生成.svg与.pdf文件为例说明)

import com.google.common.io.Files;//进行文件写入操作
public static boolean transform(String svgValue,String svgPath,String pdfPath){ // 
String command = GojaConfig.getProperty("exportCommand"); // 通过配置文件获取命令行字符串
final File svgFile = new File(svgPath);
final File pdfFile = new File(pdfPath);
command = String.format(command, svgFile, pdfFile); // 根剧参数格式化字符串 command = “---- %s --- %s”
try {
Files.write(svgValue, svgFile, Charsets.UTF_8);
Process pro = Runtime.getRuntime().exec(command); // 调用命令行执行command命令
pro.waitFor(); // 等待执行结束
} catch (IOException e) {
return false;
} catch (InterruptedException e) {
return false;
}
return true;
}
posted @ 2017-06-23 15:40  Yishin  阅读(1763)  评论(3)    收藏  举报