html模板
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>PDF Template</title>
</head>
<body>
<h1>User Information</h1>
<p>Name: <span th:text="${user.name}"></span></p>
[[${user.getName()}]]
[[${user.name}]]111
<p>Email: <span th:text="${user.email}"></span></p>
</body>
</html>
依赖
<!-- thymeleaf for html to pdf -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>${org.thymeleaf.version}</version>
<scope>compile</scope>
</dependency>
PDFGenerator
import org.springframework.stereotype.Com