起源:
项目中用到使用html转pdf功能,将开发过程中,几个主要功能提炼出来,分享给大家并有github例子,clone下来配置好jdk就能直接跑例子,代码和逻辑也超简单,一看就能明白。
环境配置:
jdk1.8.0_77 idea win10
htmlpdf版本如下
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>html2pdf</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
项目地址:https://github.com/patrickWuP/html2pdf
项目解析:
项目主要分三块:
一:快速将html转换为pdf,在 com.wp.html2pdf.simple.QuickHtml2Pdf 文件下,有三种方式将html转换为pdf(html2pdf工具类本身提供不止三种);
二:将中文html文件转换为pdf并支持粗细字体;SimSun-01.ttf(细字体)Dengb.ttf(粗字体&#