2013-09-25 58 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

哦謝謝..我現在正在使用模擬器,我沒有正確檢查目的地。同一個文件已經創造了很多時間。以上提到的錯誤可能是一個警告,因爲我仍然得到該錯誤,但工作正常。 –