Itext的简单应用和学习
来源:互联网 发布:游戏攻略软件 编辑:程序博客网 时间:2024/06/06 03:03
1.Itext使用需要使用itext.jar包。
2.Itext使用中文,主要有两种方式,下载itextasian.jar包,或者使用本地计算机字体。
本地计算机字体:
<span style="font-size:12px;"> BaseFont bfHei = BaseFont.createFont("c:/Windows/fonts/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); Font font = new Font(bfHei, 32); String text = "这是黑体字测试!"; document.add(new Paragraph(text, font));</span>使用iTextAsian.jar中的字体:
<span style="font-size:12px;"> BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);</span>3.Itext简单实例使用。
Document document = new Document(PageSize.A3); document.addAuthor("Ryan"); document.addCreationDate(); try {PdfWriter.getInstance(document, new FileOutputStream("test.pdf")); document.open();//Chunk chunk = new Chunk("Holle 乐", new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED), 32));document.add(new Paragraph("Holle world!"));<span style="white-space:pre"></span>Table table = new Table(3);table.setBorderWidth(1);table.setBorderColor(new Color(0, 0, 255));table.setPadding(5);Cell cell = new Cell("header");cell.setHeader(true);cell.setColspan(3);table.addCell(cell);cell = new Cell("example cell with colspan 1 and rowspan 2");cell.setRowspan(2);cell.setBorderColor(new Color(255, 0, 0));table.addCell(cell);table.addCell("1.1");table.addCell("2.1");table.addCell("1.2");table.addCell("2.2");table.addCell("cell test1");cell = new Cell("big cell");cell.setRowspan(2);cell.setColspan(2);cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));table.addCell(cell);table.addCell("cell test2");document.add(table);//document.add(chunk);BaseFont bfHei = BaseFont.createFont("c:/Windows/fonts/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);Font font = new Font(bfHei, 32);String text = "这是黑体字测试!";document.add(new Paragraph(text, font));document.close(); } catch (FileNotFoundException e) {e.printStackTrace(); } catch (DocumentException e) {e.printStackTrace(); } catch (IOException e) {e.printStackTrace(); }
0 0
- Itext的简单应用和学习
- iText的简单应用
- iText的简单应用
- iText的简单应用
- iText的简单应用
- iText的简单应用
- iText的简单应用-表格
- iText简单应用之二
- iText的简单应用-图象和文本的绝对位置
- iText的简单应用-图象和文本的绝对位置
- itext的学习使用
- iText的学习一 Paragraph/Chunk/Phrase/Anchor的简单实用
- 第一部分:iText的一般应用
- cut和sort的简单应用-bash学习(1)
- Itext 学习 Paragraph (段)的用法
- iText中文教程 ==第一部分:iText的一般应用(下)
- Java iText PDF:用 iText 包生成简单的 pdf 文件
- iText模板应用问题
- A+B
- IntelliJ IDEA使用教程一 介绍&安装&配置
- Codeforces 553 C. Love Triangles
- Android开发笔记---Broadcast Receiver的简单使用
- 测试Spring和Hibernate整合时,出现的一个问题记录
- Itext的简单应用和学习
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(二)鹰眼模块
- Android studio Gradle sdl method not found ...
- Spring-Session
- Valid Anagram
- 项目开发中的反思
- unix下errno.h文件声明
- lua 介绍
- Bestcoder Round#49 1001Untitled