iText实战--PDF和iText 简介

PDF可以做如下事务

iText 5步创建PDF

复制代码
import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;


public class PdfHelloWorld {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// 1、创建Document对象.
		final Document document = new Document();
		try {
			// 2、创建Writer监听document,并将PDF流指向文件.
			PdfWriter.getInstance(document, new FileOutputStream("D:/data/iText/turorial/helloworld.pdf"));
			
			// 3、开启document
			document.open();
			
			// 4、添加一个段落到document.
			document.add(new Paragraph("Hello World."));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		// 5、关闭document
		document.close();
	}

}
相关推荐
maogewang8 小时前
清朝条约史料三册合辑:从尼布楚到辛丑条约的完整 PDF 文献汇编
pdf
开开心心就好12 小时前
版本转换工具,支持Win双系统零售批量版
linux·运维·服务器·pdf·散列表·零售·1024程序员节
DechinPhy13 小时前
使用Python免费合并PDF文件
开发语言·数据库·python·mysql·pdf
开开心心就好1 天前
免费卸载工具,可清理残留批量管理启动项
linux·运维·服务器·windows·随机森林·pdf·1024程序员节
mysusheng1 天前
2025年12月Z-Library电子书下载工具
pdf
vfvfb1 天前
pdf转图片 每一页转成图片 pdf转jpg
pdf·pdf每一页转成图片
YJlio2 天前
Python 一键拆分 PDF:按“目录/章节”建文件夹 + 每页单独导出(支持书签识别&正文识别)
开发语言·python·pdf
热河暖男2 天前
使用 Flying-Saucer-Pdf + velocity 模板引擎生成 PDF(解决中文和图片问题)
java·pdf·html·springboot
maogewang2 天前
清朝条约全集 PDF 电子版(三册合集):从尼布楚到辛丑,历史文献速存
pdf
maogewang2 天前
清朝条约全集 PDF 电子版(三册合集):从尼布楚到辛丑条约的完整史料集
pdf