Manoj wrote:
> Dear All,
>
> Currently iText uses its own standard key to encrypt the pdf files. I
> would like to know if this can be replaced by our own keys.
Are you looking for Certificate Encryption?
That's supported in iText.
Security.addProvider(new BouncyCastleProvider());
PdfReader reader = new PdfReader("original.pdf");
PdfStamper stamper =
new PdfStamper(reader, new FileOutputStream("encrypted.pdf"));
FileInputStream is = new FileInputStream("foobar.cer");
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate cert = cf.generateCertificate(is);
Certificate[] certs = new Certificate[1];
certs[0] = cert;
int[] permissions = new int[1];
permissions[0] = PdfWriter.AllowPrinting;
stamper.setEncryption(certs, permissions, PdfWriter.ENCRYPTION_AES_128);
stamper.close();
You'll need the BouncyCastle jars in your CLASSPATH,
and depending on the key you're using, you might also
need to download the "Java Cryptography Extension (JCE)
Unlimited Strength Jurisdiction Policy Files" and replace
the existing JCE jars in your JRE with the downloaded ones.
br,
Bruno
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/