thymeleaf是用来获取html数据的,毕竟是个模版,传参最终拼成html的字符串string。
获取html传入给相关组件。在网上找了N多方式。itext5,pdfbox,puppeteer,还有个google header命令行。还有问前端有没有什么好的推荐,前端直接让后端来搞。后两个没测试,看着网上说的效果不错。给我的感觉就是截图,转pdf,具体我并没有实现。itext5需要前端调整它能支持的样式。
最终选择,我的版本是最新的9.1.5
参考抄袭文章:
<!-- html 转 pdf 需要用的jar -->
<!-- https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf-itext5 -->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>