欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Java使用iText生成PDF文档的代码,javaitextpdf文档,import java.

来源: javaer 分享于  点击 39291 次 点评:110

Java使用iText生成PDF文档的代码,javaitextpdf文档,import java.


import java.io.File;import java.io.FileOutputStream;import java.io.OutputStream;import java.util.Date;import com.lowagie.text.Document;import com.lowagie.text.Paragraph;import com.lowagie.text.pdf.PdfWriter;public class GeneratePDF {    public static void main(String[] args) {        try {            OutputStream file = new FileOutputStream(new File("C:\\Test.pdf"));            Document document = new Document();            PdfWriter.getInstance(document, file);            document.open();            document.add(new Paragraph("Hello Kiran"));            document.add(new Paragraph(new Date().toString()));            document.close();            file.close();        } catch (Exception e) {            e.printStackTrace();        }    }}
相关栏目:

用户点评