2013-09-25 59 views
-1

我正在尝试创建PDF格式。我试了很多,发现了一些编码,但我仍然收到错误,我不知道如何解决它。这里是我的代码:使用android生成PDF时出错

public void GenerarPDF(View view){ 
try{ 

    Document document=new Document(); 
    File root = new File(Environment.getExternalStorageDirectory(), "Notes"); 
    if (!root.exists()) { 
     root.mkdirs(); 
    } 
    File gpxfile = new File(root, "generando.pdf"); 
    PdfWriter.getInstance(document,new FileOutputStream(gpxfile)); 
    document.open(); 
    document.add(new Paragraph("Testing testing and testing")); 
    document.close(); 

}catch(Exception e){ 
    e.printStackTrace(); 
} 
} 

logcat的错误说:

09-25 07:40:14.337: E/dalvikvm(9397): Could not find class 'org.spongycastle.cert.X509CertificateHolder', referenced from method com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj 

09-25 07:40:14.337: W/dalvikvm(9397): VFY: unable to resolve new-instance 2148 (Lorg/spongycastle/cert/X509CertificateHolder;) in Lcom/itextpdf/text/pdf/PdfReader; 

请告诉这是什么错误说,如何解决这个问题。

回答

0

确保您已在libs文件夹中添加了itextpdf jar文件。如果你使用configure build path添加了库,首先使用相同的选项删除添加的jar。然后转到工作区中的项目文件夹并创建一个libs文件夹。然后将itextpdf jar放到那里。它应该解决这个问题。我也试过这里给出的示例代码:http://itextpdf.com/examples/iia.php?id=12。它对我很好

+0

哦谢谢..我现在正在使用模拟器,我没有正确检查目的地。同一个文件已经创造了很多时间。以上提到的错误可能是一个警告,因为我仍然得到该错误,但工作正常。 –