Reputation: 11
I am trying to set password protection to a PDF, using:
I experience the following issues:
The PdfReader
, PdfStamper
and PdfWriter
class are not getting read.
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
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