package com.blog.test;
import java.io.FileOutputStream;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfAction;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfOutline;
import com.itextpdf.text.pdf.PdfWriter;
public class PdfCreater {
public static void main(String[] args) throws Exception {
new PdfCreater().init();
}
public static String FILE_DIR ="d:/";
public void init() throws Exception, DocumentException
{
//Step 1—Create a Document.
Document document = new Document();
//Step 2—Get a PdfWriter instance.
FileOutputStream outputStream = new FileOutputStream( FILE_DIR+ "createSamplePDF.pdf");
PdfWriter.getInstance(document,outputStream );
//Step 3—Open the Document.
document.open();
//Step 4—Add content.
document.add(new Paragraph("Hello World"));
//Step 5—Close the Document.
document.close();
}
}
poi之pdf之生成pdf简单实例
最新推荐文章于 2024-09-09 11:20:45 发布