|
|
@@ -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(); |
|
|
|