sayan-bose
sayan-bose

Reputation: 11

iText compatibility issue

I am trying to set password protection to a PDF, using:

I experience the following issues:

  1. The PdfReader, PdfStamper and PdfWriter class are not getting read.

  2. If I change the version of iText to 5.3.2 then the previous issue is getting solved but while execution I am getting this error:

    ClassNotFound org/bouncycastle/asn1/ANS1Encodable

Thanks in advance.

Upvotes: 0

Views: 1035

Answers (1)

Amedee Van Gasse
Amedee Van Gasse

Reputation: 7634

You need to make sure that all your jars are compatible. As you can see in this pom.xml, iText 5.3.2 expects BouncyCastle 1.47. I previously wrote 1.49, that was a typo.

<dependencies>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>1.47</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpkix-jdk15on</artifactId>
        <version>1.47</version>
        <optional>true</optional>
    </dependency>
    ...
</dependencies>

You must download the correct versions of the BouncyCastle jars and include them in your project. If you cannot download the correct versions, then your problem cannot be solved. There is no other way around it.

Upvotes: 1

Related Questions