概述
html
转pdf
是常规需求,也是一个比较让人烦躁的需求,可能出现各种不讲道理的问题 。本篇主要分析html
中存在特殊字符时,如何正常转化为pdf 的问题。其他相关注意事项可参考我的其他文章,如下。
基本的html
转pdf
。
这里介绍使用开源库openhtmltopdf 将html
转化为pdf
。更加详细的文档可参考openhtmltopdf库操作手册。
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
public class SimpleUsage
{
public static void main(String[] args) throws Exception {
try (Out