我已经尝试了各种版本的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,但我不确定从哪里开始/如何做。我找到的jars在它们的文件名中并不是很有描述性。
发布于 2013-04-27 05:12:23
SpongyCastle是安卓系统中可用的BouncyCastle加密库的替代方案。看看这个线程How to include the Spongy Castle JAR in Android?,它包含了如何将SpongyCastle库包含到项目中的详细信息。
https://stackoverflow.com/questions/16244956
复制相似问题