日期:2014-05-19 浏览次数:20692 次
public class WkHtmlToPdf {
public void buildPdf(String htmlPath , String pdfDest){
String comm = "wkhtmltopdf " + htmlPath + " " + pdfDest ;
try {
Runtime.getRuntime().exec(comm);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws InterruptedException {
new WkHtmlToPdf().buildPdf("E:/etdsreport.html", "E:/aaa.pdf");
System.out.println("Done...");
}
}
java.io.IOException: Cannot run program "wkhtmltopdf": CreateProcess error=2, ?????μ???
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at com.WkHtmlToPdf.buildPdf(WkHtmlToPdf.java:10)
at com.WkHtmlToPdf.main(WkHtmlToPdf.java:18)
Caused by: java.io.IOException: CreateProcess error=2, ?????μ???
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 5 more
Done...