We are not sure 100% what you want to do. 1. Probably you want to emulate Acrobat's behavior when user clicks on signature area and signs document. In this case we should apply standard Acrobat signature approach.
PdfReader reader =new PdfReader(src); FileOutputStream os =new FileOutputStream(dest); PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0',null,true); // Creating the appearance PdfSignatureAppearance appearance = stamper.getSignatureAppearance(); // linking PdfSignature with acroform signature filed (not necessary) appearance.setVisibleSignature("SignatureField1"); appearance.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING); // Creating the signature ExternalSignature pks =new PrivateKeySignature(pk,"SHA-256","BC"); ExternalDigest digest =new BouncyCastleDigest(); MakeSignature.signDetached(appearance, digest, pks, chain,null,null,null, 0, MakeSignature.CryptoStandard.CMS); 2. In case you want to sign a specific Dataset of an XFA form and you want the signature to be validated by Acrobat, you should use the XmlDSig approach, because Acrobat doesn't support XAdES (yet): PdfReader reader =new PdfReader(src); FileOutputStream os =new FileOutputStream(dest); PdfStamper stamper = PdfStamper.createXmlSignature(reader, os); XmlSignatureAppearance appearance = stamper.getXmlSignatureAppearance(); appearance.setXmlLocator(new XfaXmlLocator(stamper)); appearance.setXpathConstructor(new XfaXpathConstructor(XfaXpathConstructor.XdpPackage.Datasets)); ExternalSignature signature =new PrivateKeySignature(pk, digestAlgorithm,"BC"); //use signXmlDSig instead of signXades MakeXmlSignature.signXmlDSig(appearance, signature, chain); ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net 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