Hi Shashi, you're on the right path. - but in step 3. you should put placeholders in the values /ByteRange and /Contents (e.g. zeros or whatever).
- after writing out the resulting PDF (step 4.) you should work only on these placeholders, you don't need iText any more (you must not use it cause any further PDF reading and writing reorganizes your PDF and the calculated Byte ranges and signature aren't valid any more) - then calculate the Byte Ranges and replace the placeholder for /ByteRange with the calculated values. - then calculate the signature with Bouncycastle and replace its placeholder /Contents. Now you can stream the result to a file. BTW: you can use IBM PKCS-Jars from the IBM JDK, too. I found them even more inuitive than BC. But don't ask me about license issues... Regards, Peter > Hi, > > I ma doing the following steps one by one please let me know where I am > doing wrong. > > I want to sign and encrypt an existing PDF document. > > Here are the steps I follow. > > 1. I open the document in PDF reader. > 2. I creat a new PDFwriter. > 3. Do the copy of pages, Bookmars. and then add the signarue field to the > PDF document > 4. Close the PDF document and store as on temparary file. > 5. Open this temporary file . compute the signature using Bouncy Castle. > 6. Get the signed data. > 7. Add the signed date to the content field of Signature PDF object. > 8. Manipulate the byte range and close the file. > 9. Now againa opne this temporary file using reader. > 10. Pass thru the encrytor and stream it back as the final file. > > But when I open the file in the acrobat reader, It adds a new page to the > pdf document. > And then the document version is shown as 1 of 2, which means the document > has been tampered with . > > I suspect that the encryption is adding some bytes and hence the byte > range that we specified during signing process got offset. > SO should we recalculate the byte range again and modify it after > encrypting the file. Does this work? Is this the correct procedure./ > Any hep would be appreciated. > > Thanks > Shashi > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com -- NEU: Bis zu 10 GB Speicher f�r e-mails & Dateien! 1 GB bereits bei GMX FreeMail http://www.gmx.net/de/go/mail ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
