如何在 PdfBox 中详细显示创建者的签名

Posted

技术标签:

【中文标题】如何在 PdfBox 中详细显示创建者的签名【英文标题】:How to show Creator in Detail of Signature in PdfBox 【发布时间】:2021-12-26 14:39:14 【问题描述】:

我想在签名详细信息中显示创建者。在“签名是使用不可用创建的。”

这是我添加签名信息的代码:

private void signDetached(SignatureInterface signature, PDDocument document, OutputStream output) throws IOException 
    PDSignature pdSignature = new PDSignature();
    pdSignature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
    pdSignature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
    pdSignature.setName("jvmfy");
    pdSignature.setReason("Learn how to sign pdf with jvmfy.com!");

    // the signing date, needed for valid signature
    pdSignature.setSignDate(Calendar.getInstance());

    // register signature dictionary and sign interface
    document.addSignature(pdSignature, signature);

    // write incremental (only for signing purpose)
    // use saveIncremental to add signature, using plain save method may break up a document
    document.saveIncremental(output);

【问题讨论】:

【参考方案1】:

我在PDF 32000 specification 中查找Prop_Build。这在 PDFBox 示例中没有实现,在搜索“PDF Signature Build Dictionary Specification”之后,我认为这很令人困惑。但根据我在现有签名 PDF 中看到的内容,这种尝试有效:

COSDictionary pbDict = new COSDictionary();
COSDictionary appDict = new COSDictionary();
appDict.setName(COSName.NAME, "PDFBox");
pbDict.setItem(COSName.getPDFName("App"), appDict);
pdSignature.getCOSObject().setItem(COSName.getPDFName("Prop_Build"), pbDict);

【讨论】:

谢谢。我添加了代码并检查了它。 Tilman Hausherr 我还有其他问题。请帮我检查一下。太感谢了。 ***.com/questions/69933844/… 这个是给mkl的? 我想你知道这个问题,所以它会被解决。很高兴得到您的帮助。 不,我没有。我从来没有见过这样的证书。 mkl 也是这方面的专家。

以上是关于如何在 PdfBox 中详细显示创建者的签名的主要内容,如果未能解决你的问题,请参考以下文章

如何防止 Apache PDFBox 中的通用签名伪造 (USF)、增量保存攻击 (ISA)、签名包装 (SWA)

PDFBox 字段值在展平后无法显示

如何使用 Apache PDFBox 创建表格

C#如何将PDF内容显示在webform中

如何在 Mac 上的“邮件”中创建和使用电子邮件签名?

关于 Apache PDFBox 和 PDF 认证的问题