我已经研究数字签名功能好几天了,现在我已经一切正常了,是时候尝试在所有页面上打印图章了,但我做得并不好......
试图给出一个快速的简历,以显示我所做的就是创建 PdfStamper、PdfSignatureAppearance 和一个 Rectangle,然后调用
appearance.setVisibleSignature(rectangle, 1, "SIGNATURE")
Run Code Online (Sandbox Code Playgroud)
上面的第二个参数“1”是我想显示图章的页码,现在可以设为 1,因为我试图在其他页面中显示图章正在创建 PdfStamper、PdfSignatureAppearance 和一个矩形,但将其设置为第 2 页。如果它有效,我会将它放在一个循环中并不断更改页面参数。
但是为什么没有效果???好吧,接近尾声时,我调用了 MakeSignature 的一个方法,在参数中,我必须传递我创建的一个外观,如果我多次调用它,则签名仅出现在与我传递给它的最后一个外观相关的页面上。
例如:
MakeSignature.signDetached(appearance2, digest, pks, chain, null, null, null, 0, CryptoStandard.CMS);
MakeSignature.signDetached(appearance, digest, pks, chain, null, null, null, 0, CryptoStandard.CMS);
Run Code Online (Sandbox Code Playgroud)
邮票将仅显示在第一页上。
也许我可以在这里得到一些帮助???
这里是整个事情:
public String signPdfFirstTime(String src, String dest, PrivateKey pk, Certificate[] chain, String providerName, String conteudoBase64, X509Certificate cert, String alias) throws IOException, DocumentException, GeneralSecurityException
{
byte[] conteudoBinario = Base64.decode(conteudoBase64);
FileOutputStream fos = new FileOutputStream(path + File.separator + src);
fos.write(conteudoBinario);
fos.close();
File f = …Run Code Online (Sandbox Code Playgroud)