itextpdf将带复选框的html_itext转html为pdf遇到的问题

该博客介绍了如何使用iTextPDF库将包含复选框的HTML文件转换为PDF,并在过程中解决中文不显示的问题。作者提供了Java代码示例,通过设置字体解析器和添加中文字体路径来确保PDF中中文的正常显示。
摘要由CSDN通过智能技术生成

packagecom.lnjecit.util;importcom.lowagie.text.pdf.BaseFont;importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;importorg.springframework.util.ResourceUtils;importorg.xhtmlrenderer.pdf.ITextFontResolver;importorg.xhtmlrenderer.pdf.ITextRenderer;import java.io.*;importjava.net.MalformedURLException;/*** Pdf处理工具类

*

*@author* @create 2017-12-18 21:25

**/

public classPdfUtil {protected static Logger logger = LoggerFactory.getLogger(PdfUtil.class);/***

*@paramhtmlFile html文件存储路径

*@parampdfFile 生成的pdf文件存储路径

*@paramchineseFontPath 中文字体存储路径*/

public static voidhtml2pdf(String htmlFile, String pdfFile, String chineseFontPath) {//step 1

String url;

OutputStream os= null;try{

url= newFile(htmlFile).toURI().toURL().toString();

os= newFileOutputStream(pdfFile);

ITextRenderer renderer= newITextRenderer

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值