2019独角兽企业重金招聘Python工程师标准>>>
private static Configuration freemarkerCfg = null;static {freemarkerCfg = new Configuration();//freemarker的模板目录try {String pathPrefix = "/";// 为了支持能从execute jar 中获取模板文件URI uri = ClassUtils.getDefaultClassLoader().getResource("week-report-template.html").toURI();if (uri.getScheme().equals("jar")) {pathPrefix = "/BOOT-INF/classes/";}freemarkerCfg.setClassForTemplateLoading(WeekPdfReportUtil.class.getClass(), pathPrefix);freemarkerCfg.setClassicCompatible(true);} catch (Exception e) {e.printStackTrace();}}//使用String content = WeekPdfReportUtil.freeMarkerRender(data, "week-report-template.html");
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf --> <dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.11</version> </dependency> <dependency><groupId>com.itextpdf.tool</groupId><artifactId>xmlworker</artifactId><version>5.5.11</version> </dependency> <dependency><groupId>org.freemarker</groupId><artifactId>freemarker</artifactId><version>2.3.19</version> </dependency>