I am trying to sign a lot of PDF files using iText (latest version) for Java.
But I have problem with big ones. With files with size over 30 MByte (until 120
MByte) I get a signature non valid error in the Acrobat Reader (and other
readers) with this message: SigDict / Contents illegal data
The same code works well for other files with size < 30 MByte. Here is the code
I use:
***********************
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(keystore_path), keystore_password.toCharArray());
String alias = prop.getProperty("key.alias");
PrivateKey pk = (PrivateKey)ks.getKey(alias , key_password.toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader(fileIn.getPath(), ownerpassword);
PdfStamper stamper = PdfStamper.createSignature(reader, new
FileOutputStream(fileOut), '\0', null , true);
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setCrypto(pk, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
Rectangle rect = new
Rectangle(Integer.parseInt(prop.getProperty("sign.field.start.x")),
Integer.parseInt(prop.getProperty("sign.field.start.y")),
Integer.parseInt(prop.getProperty("sign.field.end.x")),
Integer.parseInt(prop.getProperty("sign.field.end.y")));
appearance.setReason(prop.getProperty("sign.field.reason"));
appearance.setLocation(prop.getProperty("sign.field.location"));
appearance.setVisibleSignature(rect,
Integer.parseInt(prop.getProperty("sign.field.page")), "SignField");
stamper.close();
***********************
I am sorry for the Cross-post on Stackoverflow but I am trying to find a
solution to this problem and so I post here too.
Thanks a lot
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php