Browse Source

修改临时文件输出路径

tags/24080901
CMM 1 year ago
parent
commit
1501a1091b
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/utils/PdfUtils.java

+ 4
- 5
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/utils/PdfUtils.java View File

@@ -44,14 +44,13 @@ public class PdfUtils {

try {
File directory = new File("");
//pdf输出路径
//临时文件输出路径
String filePath = directory.getAbsolutePath() + File.separator + "fileout";
String templatePath = ResourceUtil.getResource("").getPath();
//字体格式
String fontPath = ResourceUtil.getResource("template/simsun.ttc").getPath();
if(!new File(filePath).exists()){
new File(filePath).mkdir();
}
//字体格式
String FONT = templatePath + "template" + File.separator + "simsun.ttc";
StringBuilder stringBuilder = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(templateHtmlInputStream, StandardCharsets.UTF_8));
String line;
@@ -93,7 +92,7 @@ public class PdfUtils {
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
ITextFontResolver fontResolver = renderer.getFontResolver();
fontResolver.addFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
fontResolver.addFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.layout();
renderer.createPDF(os);
os.flush();


Loading…
Cancel
Save