我已经使用各种版本的 itext 进行了尝试,包括带有试用许可证的 itextgoogle,当我尝试运行我的代码时,我不断收到以下错误:
InputStream object = this.getResources().openRawResource(R.raw.itextkey);
LicenseKey.loadLicenseFile(object);
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + java.io.File.separator + "testPDF.pdf"));
document.open();
document.add(new Paragraph("testing"));
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
错误是:
04-26 20:18:12.761: E/dalvikvm(1927): Could not find class 'org.spongycastle.cert.X509CertificateHolder', referenced from method com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj
04-26 20:18:12.761: W/dalvikvm(1927): VFY: unable to resolve new-instance 2251 (Lorg/spongycastle/cert/X509CertificateHolder;) in Lcom/itextpdf/text/pdf/PdfReader;
我听说我需要自己构建 iText,但我不确定从哪里开始/如何做。我发现的罐子的文件名不是很有描述性。