想要读懂 itextpdf 的源代码,要多调试,对整个代码的脉络掌握个大概,形成一个目录,再分析细节。所以我的目录其实是这个源码的流程轨迹
1,先要读取pdf
public class PdfReader implements PdfViewerPreferences{
public PdfReader(String filename) throws IOException {
this((String)filename, (byte[])null);
}
public PdfReader(String filename, byte[] ownerPassword) throws IOException {
this.acroForm = null;
this.acroFormParsed = false;
this.encrypted = false;
this.rebuilt = false;
this.tampered = false;
this.password = null;
this.certificateKey = null;
this.certificate = null;
this.certificateKeyProvider = null;
this.strings = new ArrayList();
this.sharedStreams = true;
this.consolidateNamedDestinations = false;
this.remoteToLocalNamedDestinations = false;
this.lastXrefPartial = -1;
this.viewerPreferences = new PdfViewerPreferencesImp();
this.readDepth = 0;
this.password = ownerPassword;
this.tokens = new PRTokeniser(filename); // 分析1:解析pdf中的token元素,在详细的文章中分析
this.readPdf();
}
}