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;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM