itextpdf5生成document生成pdf的简单dome
package dbzx.pdf; import java.io.FileNotFoundException; import java.io.FileOutputStream; import org.junit.Test; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Paragraph; import com.itextpdf.text.pdf.PdfWriter; public class CreateSimplePdf { @Test public void createSimplePdf() throws FileNotFoundException, DocumentException { String path = "E:/demo/pdfCreat/"+System.currentTimeMillis()+".pdf";//输出pdf的路径 Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream(path)); doc.open(); doc.add(new Paragraph("test"));//在pdf中打印文本 doc.close(); } }
就算这个世道烂成一堆粪坑,那也不是你吃屎的理由