我遇到了运行时异常。我想从 android 设备创建一个 PDF 文档。为此,我使用了 iText 库。
这是我创建 PDF 的代码
Document document = new Document();
PdfWriter.getInstance(document, outStream);
document.open();
document.add(new Paragraph(data));
document.close();
代码工作正常。它正在成功创建 PDF。但它在运行时给了我一个例外说
06-14 10:09:20.491: W/dalvikvm(764): Unable to resolve superclass of Lcom/itextpdf/awt/PdfGraphics2D; (1251)
06-14 10:09:20.491: W/dalvikvm(764): Link of class 'Lcom/itextpdf/awt/PdfGraphics2D;' failed
06-14 10:09:20.491: E/dalvikvm(764): Could not find class 'com.itextpdf.awt.PdfGraphics2D', referenced from method com.itextpdf.text.pdf.PdfContentByte.createGraphics
06-14 10:09:20.491: W/dalvikvm(764): VFY: unable to resolve new-instance 480 (Lcom/itextpdf/awt/PdfGraphics2D;) in Lcom/itextpdf/text/pdf/PdfContentByte;
06-14 10:09:25.280: E/dalvikvm(764): Could not find class 'org.bouncycastle.cert.X509CertificateHolder', referenced from method com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj
06-14 10:09:25.280: W/dalvikvm(764): VFY: unable to resolve new-instance 1612 (Lorg/bouncycastle/cert/X509CertificateHolder;) in Lcom/itextpdf/text/pdf/PdfReader;
我已经完成了清理和构建,将 jar 添加到 libs 文件夹并在订单和导出时选择它,过去 2 天我做了很多研究。但没有任何帮助。根据我的知识,应该有这些可能性。
- 外部 jar 未正确加载
- PdfGraphics2D 类扩展了 java.awt.Graphics2D,这在 android 中不可用
任何帮助都将是可观的。