itextpentahopdf-readerpdfstamper

Read password protected PDF in Pentaho using UDJC


I am trying to unlock the password protected PDF using bcprov-jdk15on-1.56.jar and itextpdf-5.5.10.jar but I am getting following exception. I am using 'User Defined Java Class' task of transformation.

Exception: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package

Here is the lines of code I wrote,

String pdfFilePath = get(Fields.In, "PDFFilePath").getString(r);

String dest = pdfFilePath +"_unlocked.pdf";

try {
    PdfReader reader = new PdfReader(pdfFilePath,owner_password.getBytes());
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));

    stamper.close();
    reader.close();
}
catch(Exception e) {
    logBasic("EXCEPTION WHILE UNLOCKING PDF = " + e.getMessage());
}

Any idea, what's wrong with this?

Thanks, Nilesh


Solution

  • It seems that you have multiple BouncyCastle jars in your classpath. Try using version 1.49 which is the version iText 5.5.10 is compiled against and if it does not help, you will have to figure out which jars happen to be in your classpath and get rid of the duplicates.