Question

I've tried this with various versions of itext including itextgoogle with a trial license, and I keep getting the following error when I try to run my code:

     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();

the error is:

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;

I hear that I need to build iText on my own, but I'm not sure where to start/how to do that. The jars I'm finding aren't very descriptive in their filenames.

Was it helpful?

Solution

SpongyCastle is a alternative to the BouncyCastle cryptographic library available in Android. Look at this thread - How to include the Spongy Castle JAR in Android? which has details about how to include SpongyCastle library to the project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top