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