pdf日志
This commit is contained in:
parent
c146537684
commit
26d6efd827
|
|
@ -3,7 +3,10 @@ package com.engine.salary.util.pdf;
|
|||
import com.engine.workflow.biz.requestForm.HtmlToPdfInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
@Slf4j
|
||||
public class HtmlToPdf {
|
||||
|
|
@ -11,9 +14,9 @@ public class HtmlToPdf {
|
|||
/**
|
||||
* html转pdf
|
||||
*
|
||||
* @param toPdfTool 工具路径
|
||||
* @param srcPath html路径,可以是硬盘上的路径,也可以是网络路径
|
||||
* @param destPath pdf保存路径
|
||||
* @param toPdfTool 工具路径
|
||||
* @param srcPath html路径,可以是硬盘上的路径,也可以是网络路径
|
||||
* @param destPath pdf保存路径
|
||||
* @return 转换成功返回true
|
||||
*/
|
||||
public static boolean convert(String toPdfTool, String srcPath, String destPath) {
|
||||
|
|
@ -45,8 +48,26 @@ public class HtmlToPdf {
|
|||
HtmlToPdfInterceptor output = new HtmlToPdfInterceptor(proc.getInputStream());
|
||||
error.start();
|
||||
output.start();
|
||||
proc.waitFor();
|
||||
|
||||
BufferedInputStream err = new BufferedInputStream(proc.getErrorStream());
|
||||
BufferedReader errBr = new BufferedReader(new InputStreamReader(err));
|
||||
String lineStr = "";
|
||||
while ((lineStr = errBr.readLine()) != null) {
|
||||
//检查命令是否执行失败。
|
||||
log.info("pdf转换执行中! {}", lineStr);
|
||||
}
|
||||
if (proc.waitFor() != 0) {
|
||||
//p.exitValue()==0表示正常结束,1:非正常结束
|
||||
if (proc.exitValue() == 1) {
|
||||
log.error("pdf转换命令执行失败!");
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.error("pdf转换出错!", e);
|
||||
e.printStackTrace();
|
||||
result = false;
|
||||
} catch (Exception e) {
|
||||
log.error("pdf转换出错!", e);
|
||||
result = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue