html转pdfHTML导出PDF中文、ITEXT转HTML为PDF包括中文显示解决方案

时间:2021-08-22 04:57:48
【文件属性】:

文件名称:html转pdfHTML导出PDF中文、ITEXT转HTML为PDF包括中文显示解决方案

文件大小:11.73MB

文件格式:ZIP

更新时间:2021-08-22 04:57:48

html转pdf pdf中文显示 pdf解决方 pdf jar

1、解决中文问题 2、附字体 3、动态html拼接转pdf public static void htmlCodeComeString(String linkcss,String htmlCode, String outputFile,String title) throws Exception { OutputStream os = new FileOutputStream(outputFile); ITextRenderer renderer = new ITextRenderer(); renderer.setDocumentFromString(getConversionHtmlCode(linkcss,htmlCode,title)); ITextFontResolver fontResolver = renderer.getFontResolver(); URL fontPath = ItextUtil.class.getResource("simsun.ttc"); fontResolver.addFont(fontPath.toString(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); // 解决图片的相对路径问题 // renderer.getSharedContext().setBaseURL("file:/F:/teste/html/"); renderer.layout(); renderer.createPDF(os); System.out.println("======转换成功!"); os.close(); os.flush(); } public static void main(String[] args) { ItextUtil itextUtil = new ItextUtil(); String html = ""; html += "

"; html += ""; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += "
企业信息
登记日期2006-04-28
纳税人编号HSJIHKS002
有效标志Y
社会信用代码916101317H
评估机关代码盛世
工商注销日期2006-04-28
"; String outputFile = "D:\\pdf\\aa.pdf"; try { itextUtil.htmlCodeComeString("",html,outputFile,""); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("生成结束!!!"); }


【文件预览】:
ITEXT转HTML为PDF包括中文显示解决方案
----iText-2.0.8.jar(1.16MB)
----core-renderer-R8pre2.jar(1.03MB)
----core-renderer.jar(1.03MB)
----ItextUtil.java(4KB)
----simsun.ttc(17.37MB)

网友评论

  • 浪费积分,不要下,一点用没有 #毫无价值
  • 一般,对我没有用,有些东西可以参考