|
|
@@ -1,6 +1,8 @@ |
|
|
|
package com.ningdatech.pmapi.todocenter.utils; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.io.resource.ResourceUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.itextpdf.text.DocumentException; |
|
|
|
import com.itextpdf.text.Image; |
|
|
@@ -43,14 +45,13 @@ public class PdfUtils { |
|
|
|
try { |
|
|
|
File directory = new File(""); |
|
|
|
//pdf输出路径 |
|
|
|
String absolutePath = directory.getAbsolutePath(); |
|
|
|
String linkPath = File.separator + "pmapi" + File.separator + "src" + File.separator + "main" + File.separator + "resources"; |
|
|
|
String filePath = absolutePath + linkPath + File.separator + "template" + File.separator + "fileout"; |
|
|
|
String filePath = directory.getAbsolutePath() + File.separator + "fileout"; |
|
|
|
String templatePath = ResourceUtil.getResource("").getPath(); |
|
|
|
if(!new File(filePath).exists()){ |
|
|
|
new File(filePath).mkdir(); |
|
|
|
} |
|
|
|
//字体格式 |
|
|
|
String FONT = absolutePath + linkPath + File.separator + "template" + File.separator + "simsun.ttc"; |
|
|
|
String FONT = templatePath + File.separator + "template" + File.separator + "simsun.ttc"; |
|
|
|
StringBuilder stringBuilder = new StringBuilder(); |
|
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(templateHtmlInputStream, StandardCharsets.UTF_8)); |
|
|
|
String line; |
|
|
@@ -103,9 +104,9 @@ public class PdfUtils { |
|
|
|
// 返回生成的pdf文件字节数组 |
|
|
|
return readBytes(inputStream); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new BizException("生成pdf文件失败!"); |
|
|
|
throw new BizException("生成pdf文件失败!" + e.getMessage()); |
|
|
|
} catch (DocumentException e) { |
|
|
|
throw new BizException("生成pdf文件失败!"); |
|
|
|
throw new BizException("生成pdf文件失败!" +e.getMessage()); |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
if (null != inputStream) { |
|
|
|