Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7096908
  • 博文数量: 703
  • 博客积分: 10821
  • 博客等级: 上将
  • 技术积分: 12042
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-02 10:41
个人简介

中科院云平台架构师,专注于数字化、智能化,技术方向:云、Linux内核、AI、MES/ERP/CRM/OA、物联网、传感器、大数据、ML、微服务。

文章分类

全部博文(703)

分类: Java

2013-06-05 10:33:46

所用java包iText-2.1.2.jar,iTextAsian-1.0.jar点击(此处)折叠或打开点击(此处)折叠或打开 package atest;import java.awt.Color;import java.io.FileNotFoundException;import java.io.FileOutputStream;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.PdfWriter;public class itexttest {    /**     * [メソッドの説明を書きましょう]     * @param args     */    public static void main(String[] args) {        try {            //1.创建一个document            Document document = new Document();            //2.定义pdfWriter,指明文件输出流输出到一个文件            PdfWriter.getInstance(document,new FileOutputStream("D:itexttest.pdf"));            //3.打开文档            document.open();            //字体            Font font = new Font();            font.setFamily("STSongStd-Light");            //颜色            //font.setColor(BaseColor.BLUE);            font.setColor(Color.BLUE);            //4.添加内容            Paragraph content = new Paragraph("xxx!",font);            document.add(content);            //添加段落            for(int i=0;i<100;i++){                document.add(new Paragraph(i+1 + ":HelloWorld"+","+"Hello iText"+","+"Hello Hiya Chen"));            }            //5.关闭            document.close();        } catch (FileNotFoundException e) {            e.printStackTrace();        } catch (DocumentException e) {            e.printStackTrace();        }    }} package atest;import java.awt.Color;import java.io.FileNotFoundException;import java.io.FileOutputStream;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.PdfWriter;public class itexttest {    /**     * [メソッドの説明を書きましょう]     * @param args     */    public static void main(String[] args) {        try {            //1.创建一个document            Document document = new Document();            //2.定义pdfWriter,指明文件输出流输出到一个文件            PdfWriter.getInstance(document,new FileOutputStream("D:itexttest.pdf"));            //3.打开文档            document.open();            //字体            Font font = new Font();            font.setFamily("STSongStd-Light");            //颜色            //font.setColor(BaseColor.BLUE);            font.setColor(Color.BLUE);            //4.添加内容            Paragraph content = new Paragraph("xxx!",font);            document.add(content);            //添加段落            for(int i=0;i<100;i++){                document.add(new Paragraph(i+1 + ":HelloWorld"+","+"Hello iText"+","+"Hello Hiya Chen"));            }            //5.关闭            document.close();        } catch (FileNotFoundException e) {            e.printStackTrace();        } catch (DocumentException e) {            e.printStackTrace();        }    }}
阅读(1329) | 评论(0) | 转发(0) |
0

上一篇:使用多线程的利弊

下一篇:jfreechart的应用

给主人留下些什么吧!~~