itextpdf 简介
官网:iText 7
*********************
简 介
iText 7 is the latest version of iText's powerful PDF Toolkit for
PDF generation, PDF programming, handling & manipulation, such as
digital signing and more
# itext7是itext最新的pdf处理工具,可以用来生成pdf文档、pdf编程、执行数字签名等其他操作
itext7-core:包含很多itext开发所需的包
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext7-core</artifactId>
<version>7.2.0</version>
<type>pom</type>
</dependency>
*********************
相关类与接口
PdfDocument
public class PdfDocument implements IEventDispatcher, Closeable {
private static IPdfPageFactory pdfPageFactory = new PdfPageFactory();
private PageSize defaultPageSize; //pdf页面大小
protected EventDispatcher eventDispatcher;
protected PdfWriter writer; //写入pdf文件
protected PdfReader reader; //读取pdf文件
protected byte[] xmpMetadata;
protected PdfCatalog catalog;
protected PdfDictionary trailer; //pdf字典:内有map,key为pdfName、value为pdf对象
protected PdfDocumentInfo info; //pdf文档信息:作者、标题、关键字、创建时间等
protected PdfVersion pdfVersion; //pdf版本
private PdfString originalDocumentId;
private PdfString modifiedDocumentId;
final PdfXrefTable xref;
protected FingerPrint fingerPrint;
protected final StampingProperties properties;
protected PdfStructTreeRoot structTreeRoot;
protected int structParentIndex;
protected boolean closeReader;
protected boolean closeWriter;
protected boolean isClosing;
protected boolean closed;
protected boolean flushUnusedObjects;
private Map<PdfIndirectReference, PdfFont> documentFonts;
private PdfFont defaultFont;
protected TagStructureContext tagStructureContext;
private SequenceId documentId;
private LinkedHashMap<PdfPage, List<PdfLinkAnnotation>> linkAnnotations;
Map<PdfIndirectReference, byte[]> serializedObjectsCache;
MemoryLimitsAwareHandler memoryLimitsAwareHandler;
private EncryptedEmbeddedStreamsHandler encryptedEmbeddedStreamsHandler;
***********
构造方法
public PdfDocument(PdfReader reader) {
public PdfDocument(PdfReader reader, DocumentProperties properties) {
public PdfDocument(PdfWriter writer) {
public PdfDocument(PdfWriter writer, DocumentProperties properties) {
public PdfDocument(PdfReader reader, PdfWriter writer) {
public PdfDocument(PdfReader reader, PdfWriter writer, StampingProperties properties) {
***********
XmpMetadata
protected void setXmpMetadata(byte[] xmpMetadata) {
public void setXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions) throws XMPException {
public void setXmpMetadata(XMPMeta xmpMeta) throws XMPException {
public byte[] getXmpMetadata() {
public byte[] getXmpMetadata(boolean createNew) {
***********
pdfObject
public PdfObject getPdfObject(int objNum) {
public int getNumberOfPdfObjects() {
***********
page
public PdfPage getPage(int pageNum) {
public PdfPage getPage(PdfDictionary pageDictionary) {
public PdfPage getFirstPage() {
public PdfPage getLastPage() {
public PdfPage addNewPage() {
public PdfPage addNewPage(PageSize pageSize) {
public PdfPage addNewPage(int index) {
public PdfPage addNewPage(int index, PageSize pageSize) {
public PdfPage addPage(PdfPage page) {
public PdfPage addPage(int index, PdfPage page) {
public int getNumberOfPages() {
public int getPageNumber(PdfPage page) {
public int getPageNumber(PdfDictionary pageDictionary) {
public boolean movePage(PdfPage page, int insertBefore) {
public void movePage(int pageNumber, int insertBefore) {
public boolean removePage(PdfPage page) {
public void removePage(int pageNum) {
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage) {
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier) {
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument) {
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, IPdfPageExtraCopier copier) {
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, int insertBeforePage) {
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier) {
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument) {
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, IPdfPageExtraCopier copier) {
public PageSize getDefaultPageSize() {
public void setDefaultPageSize(PageSize pageSize) {
public void flushCopiedObjects(PdfDocument sourceDoc) {
***********
font
public PdfFont getFont(PdfDictionary dictionary) {
public PdfFont getDefaultFont() {
public PdfFont addFont(PdfFont font) {
public PdfFont findFont(String fontProgram, String encoding) {
***********
文档信息
public PdfDocumentInfo getDocumentInfo() {
public PdfString getOriginalDocumentId() {
public PdfString getModifiedDocumentId() {
public long getDocumentId() {
public SequenceId getDocumentIdWrapper() {
***********
event
public void addEventHandler(String type, IEventHandler handler) {
public void dispatchEvent(Event event) {
public void dispatchEvent(Event event, boolean delayed) {
public boolean hasEventHandler(String type) {
public void removeEventHandler(String type, IEventHandler handler) {
public void removeAllHandlers() {
***********
reader、writer
public PdfWriter getWriter() {
public PdfReader getReader() {
***********
其他操作
p