问题描述
- itext签名后不执行签名域属性怎么解决?
- 通过手动签名以后可以正常执行签名域的属性但是通过代码完成签名以后,签名属性不能执行。标记的只读的域还是能操作。
代码如下KeyStore ks = KeyStore.getInstance(""pkcs12""); ks.load(new FileInputStream(certSrc) certPassword.toCharArray()); String alias = (String) ks.aliases().nextElement(); PrivateKey key = (PrivateKey) ks.getKey(alias certPassword.toCharArray()); Certificate[] chain = ks.getCertificateChain(alias); PdfReader reader = new PdfReader(pdfSrcpdfPassword.getBytes()); // FileOutputStream fout = new FileOutputStream(new File(donePdfSrc)); PdfStamper stp = PdfStamper.createSignature(reader fout ''nullfalse); PdfSignatureAppearance sap = stp.getSignatureAppearance(); sap.setReason(reason); sap.setLocation(location); Image image = Image.getInstance(imageSrc); sap.setSignatureGraphic(image); String url = SignPDF.class.getResource(""simsun.ttc"").toString()+""0""; BaseFont bfChinese = BaseFont.createFont(url.toString()BaseFont.IDENTITY_HBaseFont.NOT_EMBEDDED);// Font fontChinese = new Font(bfChinese12Font.NORMAL); sap.setLayer2Font(fontChinese);// sap.setLayer2Text(reason);// sap.setLayer4Text(""setLayer4Text"");// sap.setRenderingMode(RenderingMode.GRAPHIC_AND_DESCRIPTION); sap.setVisibleSignature(fieldName); stp.getWriter().setCompressionLevel(5); Security.addProvider(new BouncyCastleProvider()); ExternalSignature es = new PrivateKeySignature(keySHA-256""BC""); ExternalDigest digest = new BouncyCastleDigest(); MakeSignature.signDetached(sap digest es chain null null null 0 CryptoStandard.CMS);
有没有哪个大神帮忙解答下,
解决方案
http://bbs.csdn.net/topics/390166269
时间: 2024-10-29 09:44:49