itext生成pdf文件的HelloWorld

public class HelloWorld {

	public static void main(String args[]) throws FileNotFoundException, DocumentException {
		
		String fileName = "pdf/helloWorld.pdf";
		String content = "Hello World!";
		create(fileName, content);
		
	}
	
	private static void create(String fileName, String content) throws DocumentException, FileNotFoundException {
		
		//step1
		Document document = new Document();
		OutputStream os = new FileOutputStream(fileName);
		//step2
		PdfWriter.getInstance(document, os);
		//step3
		document.open();
		//step4
		document.add(new Paragraph(content));
		//step5
		document.close();
	}
	
}

 

上一篇:Ubuntu 17.10 (Artful Aardvark) 目标使用Linux 4.13内核系列


下一篇:威胁情报分析工具