daidalei321

itext导出pdf字体设置

  • 博客分类:
  • java

import java.io.FileOutputStream;

import java.io.IOException;

import com.lowagie.text.Document;

import com.lowagie.text.DocumentException;

import com.lowagie.text.Font;

import com.lowagie.text.Paragraph;

import com.lowagie.text.pdf.BaseFont;

import com.lowagie.text.pdf.PdfWriter;

public class test {

public static void main(String[] args) {

// TODO Auto-generated method stub

// step 1: creation of a document-object

Document document = new Document();

try {

// step 2:

// we create a writer that listens to the document

// and directs a PDF-stream to a file

PdfWriter.getInstance(document, new FileOutputStream("D:\\ChinesePDF005_"+new

java.util.Date().getTime()+".pdf"));

// step 3: we open the document

document.open();

//  step 4: we add content to the document

// 楷体字

BaseFont bfComic = BaseFont.createFont("c:\\windows\\fonts\\simkai.ttf",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

// 方正舒体

BaseFont bfComic2 = BaseFont.createFont("c:\\windows\\fonts\\FZSTK.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

// 方正姚体

BaseFont bfComic3 = BaseFont.createFont("c:\\windows\\fonts\\FZYTK.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
//
         //   仿宋体

BaseFont bfComic4 = BaseFont.createFont("c:\\windows\\fonts\\SIMFANG.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

//  黑体

BaseFont bfComic5 = BaseFont.createFont("c:\\windows\\fonts\\SIMHEI.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

// 华文彩云

BaseFont bfComic6 = BaseFont.createFont("c:\\windows\\fonts\\STCAIYUN.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

//华文仿宋

BaseFont bfComic7 = BaseFont.createFont("c:\\windows\\fonts\\STFANGSO.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

// 华文细黑

BaseFont bfComic8 = BaseFont.createFont("c:\\windows\\fonts\\STXIHEI.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

//  华文新魏

BaseFont bfComic9= BaseFont.createFont("c:\\windows\\fonts\\STXINWEI.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

//华文行楷

BaseFont bfComic0 = BaseFont.createFont("c:\\windows\\fonts\\STXINGKA.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

// 华文中宋

BaseFont bfComic99 = BaseFont.createFont("c:\\windows\\fonts\\STZHONGS.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

//隶书

BaseFont bfComic11= BaseFont.createFont("c:\\windows\\fonts\\SIMLI.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

//宋体&新宋体    (这种字体的输出不了.有问题)

//   BaseFont bfComic12 = BaseFont.createFont("c:\\windows\\fonts\\SIMSUN.TTC", null,

BaseFont.NOT_EMBEDDED, BaseFont.NOT_EMBEDDED, null, null);

//宋体-方正超大字符集

BaseFont bfComic13 = BaseFont.createFont("c:\\windows\\fonts\\SURSONG.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

//幼圆

BaseFont bfComic14 = BaseFont.createFont("c:\\windows\\fonts\\SIMYOU.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

Font font = new Font(bfComic0, 14);

String text1 = "啊发生的发球特工是大哥是法国时的风格是This is the quite popular True Type

font (繁體字測試VS简体字测试) ==>"+new java.util.Date();

document.add(new Paragraph(text1, font));

}

catch(DocumentException de) {

System.err.println(de.getMessage());

}

catch(IOException ioe) {

System.err.println(ioe.getMessage());

}

// step 5: we close the document

document.close();

System.out.println(">>> Export : "+"D:\\ChinesePDF005__.pdf");

}

}

面试时如何在众多Java工程师中脱颖而出?
Java 程序员必备的知识盘点, Java从小白到大牛的学习规划!
1
4

分享到:
  <a href="/blog/1115059" class="pre" title="固定table表头">固定table表头</a>
</div>
  • 2011-08-19 10:17
  • 浏览 8781
  • 评论(0)
  •   <li>分类:<a href="https://www.iteye.com/blogs/category/language">编程语言</a></li>      <li class="last"><a href="https://www.iteye.com/wiki/blog/1153078" target="_blank" class="more">查看更多</a></li>
    </ul>
    
评论
发表评论

您还没有登录,请您登录后再发表评论

相关资源推荐
  •                   <li class="news-recommends-ajax"><a href="https://blog.csdn.net/sprionzgyp/article/details/79583391" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/sprionzgyp/article/details/79583391,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="使用iText导出PDF文件(支持中文,解析html)">使用<em class="related_suggestion_highlight">iText</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">PDF</em>文件(支持中文,解析html)</a><p>导读:本文介绍如何使用<em class="related_suggestion_highlight">iText</em><em class="related_suggestion_highlight">Pdf</em><em class="related_suggestion_highlight">导出</em>中文<em class="related_suggestion_highlight">PDF</em>文件,不当之处,请指出。一:前期准备1,加入依赖: &amp;amp;lt;!--<em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">pdf</em>相关--&amp;amp;gt;&amp;amp;lt;dependency&amp;amp;gt;&amp;amp;lt;groupId&amp;amp;gt;com.<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">pdf</em>&amp;amp;lt;/groupId&amp;amp;gt;&amp;amp;lt;artifactId&amp;amp;gt;<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">pdf</em>&amp;amp;lt;/a...</p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/u011498933/article/details/56843547" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/u011498933/article/details/56843547,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="Itext设置导出word文件的字体"><em class="related_suggestion_highlight">Itext</em>设置<em class="related_suggestion_highlight">导出</em>word文件的字体</a><p>首先,要导入<em class="related_suggestion_highlight">Itext</em>的三个jar包:<em class="related_suggestion_highlight">iText</em>-2.1.7.jar,<em class="related_suggestion_highlight">itext</em>-rtf-2.1.7.jar,<em class="related_suggestion_highlight">iText</em>Asian.jar;
    

其次,Itext里面设置导出word文件的字体,用RtfFont这个类的初始化方法进行设置;
 RtfFont font =new RtfFont(“仿 宋”, 12, Font.NORMAL, Color.BLACK);
这个构造方法里面:第一个参数

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/xxj_jing/article/details/70888801" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/xxj_jing/article/details/70888801,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/xxj_jing/article/details/70888801,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="java-pdf-itext 生成pdf 文档(支持中文字体)">java-<em class="related_suggestion_highlight">pdf</em>-<em class="related_suggestion_highlight">itext</em> 生成<em class="related_suggestion_highlight">pdf</em> 文档(支持中文字体)</a><p>java-<em class="related_suggestion_highlight">pdf</em>-<em class="related_suggestion_highlight">itext</em> 生成<em class="related_suggestion_highlight">pdf</em> 文档(支持中文字体)

itext 版本:2.1.7

package com.demo.preview;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOExceptio

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/xxj_jing/article/details/72714580" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/xxj_jing/article/details/72714580,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/xxj_jing/article/details/72714580,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="java-pdf-itext7、itextpdf 生成pdf 文档,使用pdf模板生成(支持中文字体)">java-<em class="related_suggestion_highlight">pdf</em>-<em class="related_suggestion_highlight">itext</em>7、<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">pdf</em> 生成<em class="related_suggestion_highlight">pdf</em> 文档,使用<em class="related_suggestion_highlight">pdf</em>模板生成(支持中文字体)</a><p>java-<em class="related_suggestion_highlight">pdf</em>-<em class="related_suggestion_highlight">itext</em>7、<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">pdf</em> 生成<em class="related_suggestion_highlight">pdf</em> 文档(支持中文字体)

itext7 内置对中文(CJK字体)进行了支持,不在依赖其他组件。
//处理中文问题  
PdfFont font = PdfFontFactory.createFont(“STSongStd-Light”, “UniGB-UCS2-H”, false);

一、iText 7 资料:

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/daidalei/article/details/84004244" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/daidalei/article/details/84004244,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/daidalei/article/details/84004244,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="itext导出pdf字体设置"><em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">pdf</em><em class="related_suggestion_highlight">字体设置</em></a><p></p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/sun215153/article/details/9715623" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/sun215153/article/details/9715623,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/sun215153/article/details/9715623,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="Itext导出PDF,linux下字体 不能显示的问题"><em class="related_suggestion_highlight">Itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">PDF</em>,linux下字体 不能显示的问题</a><p>这个问题纠结了好久,最后解决的办法是,将windows下面的字体<em class="related_suggestion_highlight">导出</em>成一个jar放入项目,就可以了。</p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/LWJdear/article/details/78655504" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/LWJdear/article/details/78655504,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/LWJdear/article/details/78655504,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="【java】 iText使用PDF模板生成输出PDF  这个比较清晰">【java】 <em class="related_suggestion_highlight">iText</em>使用<em class="related_suggestion_highlight">PDF</em>模板生成输出<em class="related_suggestion_highlight">PDF</em>  这个比较清晰</a><p>转载自:http://blog.csdn.net/leeyefang/article/details/46805617

本文所要用到的工具或jar主要有:

Adobe Acrobat 这个主要用来制作PDF模板、eclipse、 itext.jar、 解决中文的输出问题,需要多下载一个名为iTextAsian.jar的JAR包。这个包里面定义了与中文输出相关的一些文件。

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/weixin_37690143/article/details/79817050" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/weixin_37690143/article/details/79817050,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/weixin_37690143/article/details/79817050,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="利用itext将html文件转化pdf文件(四)——字体样式">利用<em class="related_suggestion_highlight">itext</em>将html文件转化<em class="related_suggestion_highlight">pdf</em>文件(四)——字体样式</a><p>在利用<em class="related_suggestion_highlight">itext</em>将html文件转化为<em class="related_suggestion_highlight">pdf</em>文件的过程中,需要适当的调整字体,下面介绍字体的使用样式:字体支持的样式&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <em class="related_suggestion_highlight">itext</em>核心库中主要支持一下几个各种的字体文件:.AFM/.PFB/.TTF/.otf/.ttc/.wof&nbsp; &nbsp; 2. &nbsp;利用DefaultFontProvider&nbsp;只是支持&nbsp;14&nbsp;Standard Type 1&nbsp;fonts and 12 fonts&nbsp;主要字体...</p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/tangedegushi/article/details/81539320" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/tangedegushi/article/details/81539320,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/tangedegushi/article/details/81539320,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="Android使用Itext生成pdf文件">Android使用<em class="related_suggestion_highlight">Itext</em>生成<em class="related_suggestion_highlight">pdf</em>文件</a><p>对于生成<em class="related_suggestion_highlight">pdf</em>文件,上一篇文章介绍了使用android原生的方式生成<em class="related_suggestion_highlight">pdf</em>,使用android原生的方式对于将view上的内容生成<em class="related_suggestion_highlight">pdf</em>非常的简单,但有缺憾,就是生成的<em class="related_suggestion_highlight">pdf</em>文佳很多,对于在项目中需要将生成的<em class="related_suggestion_highlight">pdf</em>文件发送出去,这时就会发现发送的时间有点长了,这对于用户来说肯定是不可以接受的了,所以就有了这里接受的<em class="related_suggestion_highlight">Itext</em>了。

对于Itext,主要有两个版本,一个是5.x,另一个是7.x,这两…

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/u012151597/article/details/52900049" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/u012151597/article/details/52900049,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/u012151597/article/details/52900049,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="java 使用itext导出PDF文件,图片文字左右布局">java 使用<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">PDF</em>文件,图片文字左右布局</a><p>java 使用<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">PDF</em>文件,带图片布局。<em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">pdf</em>效果如下代码代码块语法遵循标准markdown代码,例如:/**
  • 思路:使用嵌套表格对象完成数据,图片左右布局

  • 1、创建document对象。

  • 2、创建表格对象PdfPTable headerTable。两列的表格对象。图片分为一列,数据划分为一列。

  • 3、创建左边数据表格PdfPTable iTable,划分为N列

  •               <li class="news-recommends-ajax"><a href="https://blog.csdn.net/qq876551724/article/details/81095703" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/qq876551724/article/details/81095703,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/qq876551724/article/details/81095703,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="Java解决Itext pdf中文不显示问题(保留html属性的方式)">Java解决<em class="related_suggestion_highlight">Itext</em> <em class="related_suggestion_highlight">pdf</em>中文不显示问题(保留html属性的方式)</a><p>Java解决<em class="related_suggestion_highlight">Itext</em> <em class="related_suggestion_highlight">pdf</em>中文不显示问题</p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/u012283400/article/details/72782976" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/u012283400/article/details/72782976,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/u012283400/article/details/72782976,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="Java利用Itext导出pdf">Java利用<em class="related_suggestion_highlight">Itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">pdf</em></a><p>本文概述了如何通过<em class="related_suggestion_highlight">Itext</em>生成包含表格的<em class="related_suggestion_highlight">pdf</em>文档,包含简单的表格格式设置,迭代添加表格数据等实践。解决了中文字不能显示或显示乱码的问题。最后输出到HttpResponse流中供用户下载。本文提供的示例较为直观简单,仅做抛砖引玉之用。jar包下载
    

itextpdf-5.3.2.jar
itext-asian.jar(解决中文显示)
Itext使用工具类/**

  • @author zhangt

  •                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/weixin_41478499/article/details/80217087" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/weixin_41478499/article/details/80217087,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/weixin_41478499/article/details/80217087,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="利用iText技术导出PDF到本地">利用<em class="related_suggestion_highlight">iText</em>技术<em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">PDF</em>到本地</a><p>//从数据库将数据表格用<em class="related_suggestion_highlight">pdf</em><em class="related_suggestion_highlight">导出</em>
    

//模拟列表数据
List&amp;lt;String[]&amp;gt; list = new ArrayList&amp;lt;&amp;gt;();

    String[] ss1={&amp;quot;七月份&amp;quot;,&amp;quot;1999&amp;quot;,&amp;quot;800&amp;quot;};String[] ss2={&amp;quot;八月份&amp;quot;,&amp;quot;2999&amp;quot;,&amp;quot;900&amp;quot;};St</p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/xygg0801/article/details/53286502" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/xygg0801/article/details/53286502,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/xygg0801/article/details/53286502,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="使用iText导出word和pdf(经典)">使用<em class="related_suggestion_highlight">iText</em><em class="related_suggestion_highlight">导出</em>word和<em class="related_suggestion_highlight">pdf</em>(经典)</a><p></p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/qq_39028580/article/details/80292642" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/qq_39028580/article/details/80292642,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/qq_39028580/article/details/80292642,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="JAVA ITEXT5 导出为PDF(三) HTML页面导出PDF文件">JAVA <em class="related_suggestion_highlight">ITEXT</em>5 <em class="related_suggestion_highlight">导出</em>为<em class="related_suggestion_highlight">PDF</em>(三) HTML页面<em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">PDF</em>文件</a><p>在(一)的背景下,直接将HTML页面<em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">PDF</em>文件(此情况数据<em class="related_suggestion_highlight">导出</em>不完整):// step 1

Document document = new Document();
// step 2
// response.setContentType(&quot;application/pdf&quot;);
response.setHeader(&quot;Content-Disposition&quot;, &quot;attachment;filen…

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/zhuce0001/article/details/51964860" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/zhuce0001/article/details/51964860,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/zhuce0001/article/details/51964860,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="iText生成pdf中文字体解决方案"><em class="related_suggestion_highlight">iText</em>生成<em class="related_suggestion_highlight">pdf</em>中文字体解决方案</a><p>相信用过<em class="related_suggestion_highlight">itext</em>的朋友都知道,中文显示一直都是个问题(最新版5.5.7官方也没直接集成中文字体)。

当然这样的问题,早就有高手解决了,那就是使用iTextAsian.jar。
但是本文介绍的,不是使用iTextAsian.jar,而是另一种解决方法。
在此之前,需要准备的仅仅为itextpdf-5.x.jar 和一个 ttf格式的中文字体。比如我们常用的宋体simsun.ttf。
我们首

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/Feb_kylin/article/details/79105630" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/Feb_kylin/article/details/79105630,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/Feb_kylin/article/details/79105630,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="java使用itext导出pdf,图片、表格、背景图">java使用<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">pdf</em>,图片、表格、背景图</a><p><em class="related_suggestion_highlight">导出</em>效果如下代码1、常用的几个方法放到了一个工具类中import com.<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">pdf</em>.text.Element;

import com.itextpdf.text.Font;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;

/**

  • @Description: pdf工具类

  • @a

  •                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/weixin_37690143/article/details/79813556" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/weixin_37690143/article/details/79813556,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/weixin_37690143/article/details/79813556,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="利用iText将html转为pdf设置不同的样式以及报表">利用<em class="related_suggestion_highlight">iText</em>将html转为<em class="related_suggestion_highlight">pdf</em>设置不同的样式以及报表</a><p>本教程只是作为自己的总结使用,主要参考于官网的文档:https://developers.<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">pdf</em>.com/这个是一系列的介绍的方式,转化<em class="related_suggestion_highlight">pdf</em>入门请转入:利用<em class="related_suggestion_highlight">itext</em>将html文件转化<em class="related_suggestion_highlight">pdf</em>文件这里我们介绍几个关于<em class="related_suggestion_highlight">pdf</em>输出的形式。1、将生成的<em class="related_suggestion_highlight">pdf</em>文件作为输出的媒体形式在这里面引入MediaDeviceDescription属性,用来设置ConverterProperties添加在转...</p></li><li class="news-recommends-ajax"><a href="https://blog.csdn.net/JE_GE/article/details/84834529" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/JE_GE/article/details/84834529,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/JE_GE/article/details/84834529,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="Spring Boot 系列教程18-itext导出pdf下载">Spring Boot 系列教程18-<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">pdf</em>下载</a><p>Java操作<em class="related_suggestion_highlight">pdf</em>框架
    

iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本,表格,图形的只读文档是很有用的。它的类库尤其与java Servlet有很好的给合。使用iTextPDF能够使你正确的控制Servlet的输出。

http://itextpdf.com/

最终下载效果

pom.xml

&amp;lt;!-- itext方式…

                 <li class="news-recommends-ajax"><a href="https://blog.csdn.net/wjx_jasin/article/details/80591531" data-track-click="{&quot;con&quot;:&quot;,https://blog.csdn.net/wjx_jasin/article/details/80591531,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" data-track-view="{&quot;con&quot;:&quot;,https://blog.csdn.net/wjx_jasin/article/details/80591531,-&quot;,&quot;mod&quot;:&quot;popu_712&quot;}" target="_blank" title="【pdf】使用itext生成pdf的,各种布局和使用itext导出pdf,图片、表格、背景图">【<em class="related_suggestion_highlight">pdf</em>】使用<em class="related_suggestion_highlight">itext</em>生成<em class="related_suggestion_highlight">pdf</em>的,各种布局和使用<em class="related_suggestion_highlight">itext</em><em class="related_suggestion_highlight">导出</em><em class="related_suggestion_highlight">pdf</em>,图片、表格、背景图</a><p>一、使用<em class="related_suggestion_highlight">itext</em>生成<em class="related_suggestion_highlight">pdf</em>的,各种布局代码如下,jar包为<em class="related_suggestion_highlight">itext</em>.jar,<em class="related_suggestion_highlight">itext</em>Asia.jar,最好都是最新的 ;2张图片也在最后贴出,把图片放到D盘可以直接生成制定格式的<em class="related_suggestion_highlight">pdf</em>。&nbsp;最后生成的<em class="related_suggestion_highlight">pdf</em>如下:&nbsp;代码如下:package com.<em class="related_suggestion_highlight">itext</em>.test;

import java.io.FileOutputStream;

import com.itextpdf.text.Ba…

     </ul></div>
  </div>

itextpdf 更换字体相关推荐

  1. altium Designer丝印显示汉字,更换字体,数码管风格,镂空效果

    1.首先勾选"TrueType",即丝印使用矢量字体.这时就可以正常显示汉字了. 2.勾选"TrueType"后,可以在下面的"Font Name&q ...

  2. intellig idea中jsp或html数据没有自动保存和更换字体

    主题一:保存数据jsp intellig idea是自动保存数据的,看到没有保存 解决方案: 成功解决 主题二:更换字体: 或者快捷键Ctel+Alt+s 成功解决 转载于:https://www.c ...

  3. 在 Ubuntu 中更换字体

    环境 Ubuntu 18.04.3 LTS 下载并解压字体 首先,下载要安装的字体.在本教程中,我们将使用Hack字体.用wget从github中下载字体: wget https://github.c ...

  4. fixedsys字体 win7_fixedsys字体 win7_帮您win7系统记事本像Word文档一样更换字体的解决步骤...

    很多人在时候电脑的过程中会发现win7系统记事本像Word文档一样更换字体的问题,据小编了解,不是所有的用户都会解决win7系统记事本像Word文档一样更换字体的问题,因此我就在电脑上汇集整顿出win ...

  5. fixedsys字体 win7_帮您win7系统记事本像Word文档一样更换字体的解决步骤

    很多人在时候电脑的过程中会发现win7系统记事本像Word文档一样更换字体的问题,据小编了解,不是所有的用户都会解决win7系统记事本像Word文档一样更换字体的问题,因此我就在电脑上汇集整顿出win ...

  6. iPhone更换字体教程,无需越狱,支持所有苹果设备!

    上周开始,技术大神@zhuowei  发现了一个iOS系统更换字体的漏洞,经过不断修正,现在已经可利用上了! 先来看看更换字体后的效果,更换之后,所有App上的字体都得到更改,下图是打开文章的效果 下 ...

  7. 搜狗输入法更换字体与皮肤

    图标上右键-更多-属性设置 效果: 注意:如果是新安装的字体,更换中文字体但其中列表没有显示,可以取消更换字体前面的对钩后,重新选择对钩,此时就显示新的中文字体了

  8. 手机更换字体导致循环重启

    手机更换字体导致循环重启 我把手机字体改了后,但忘记了修改权限(或者字体管家之类软件更改失败)导致手机不停的重启,但就是开不了机. 这时该怎么办了??刷机?? 不,没这必要.recovery+adb工 ...

  9. 将指定格式的文字进行格式替换更换字体颜色、字号、字形等

    编辑文档时,有时会遇到需要将指定格式的文字进行格式替换,更换字体颜色.字号.字形等,例如将红色文字替换为微软雅黑.加粗.蓝色,如图 7‑15所示,该怎么办呢? 图7‑15替换红色字体 解决方案 查找目 ...

  10. android 程序更换字体,Android修改自己程序字体的方法详解

    Android提供三种字体:"Sans","serif"和"monospace". 1.在Android XML文件中设置字体可以采用and ...

最新文章

  1. ecliplse 调试android 断点,如何在Github maven项目上开始调试
  2. Ubuntu安装docker-ce,vagrant,virtualbox步骤
  3. 【转载】哈希表的原理,真的很难弄懂么?
  4. docker网络原理
  5. 暴走英雄坛html5游戏在线玩,暴走英雄坛h5
  6. partition by 函数
  7. EDM营销之如何使邮件列表更加有效
  8. 周博磊自述5年研究经历:一个神经元的价值和一个神经病的坚持
  9. python renamer模块_artellapipe-tools-renamer-以简单的方式重命名DCC对象的工具-Tomas Poveda...
  10. excel导入到mysql
  11. 谜题27:变幻莫测的i值
  12. call mysql_connect_Call to undefined function mysql_connect()
  13. C# SOCKE通信
  14. C#正则表达式提取txt小说目录
  15. 教你写脚本屏蔽百度广告 csdn广告
  16. 饮用水公司配送管理系统可行性报告
  17. 阿里云域名的注册到使用流程
  18. DNS服务器常见的攻击方式
  19. MDK中编译报错 Error: L6218E: Undefined symbol SystemInit (referred from startup_cmsdk_cm0.o).
  20. threejs LOD

热门文章

  1. 竞品分析 | 荔枝VS喜马拉雅FM:有声音频APP的发展与社交
  2. Flash游戏开发必备书籍
  3. 安卓psp模拟器联机教程_psp模拟器联机游戏下载-psp模拟器联机对战版v1.0 安卓版 - 极光下载站...
  4. 30款硬盘有问题 细看希捷固件门事件.
  5. 国内免费CMS系统大全
  6. mongodb3 重启_冰点还原的安装配置,每次重启就会还原系统软件。
  7. Python 文件路径
  8. 电脑关机程序(源码)
  9. android root刷机包包,安卓ROOT卡刷包通用版【安致提供】
  10. 怎样屏蔽掉“网页对话框”