pe:documentViewer 不显示 PDF 中的数字签名

Tat*_*tha 2 pdf primefaces primefaces-extensions pdf.js

我有一个多格式文档查看器,在其中,为了显示 PDF,我使用 PF Extension 的p:documentViewer组件。提供 PDF StreamedContent 的支持 bean 已进行阶段渲染并按预期工作。然而,尽管 PDF 本身渲染得很好,但查看者不会显示其中的数字签名p:documentViewer使用时需要添加额外的配置吗?这是我的用法:

<pe:documentViewer id="pdfVw" height="600" width="800" value="#{viewerController4.pdfDocumentStream}">                                           
    <f:param name="id" value="#{viewerController4.currentDocId}" /> 
</pe:documentViewer> 
Run Code Online (Sandbox Code Playgroud)

提供 PDF 内容的支持 bean 方法:

public StreamedContent getPdfDocumentStream() throws IOException {
        FacesContext context = FacesContext.getCurrentInstance();

        if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
            return new DefaultStreamedContent();
        } else {
            String id = context.getExternalContext().getRequestParameterMap().get("id");
            Doc doc = pdfDocMap.get(id);

            return new DefaultStreamedContent(new FileInputStream(new File(doc.getDocPath())), "application/pdf", doc.getDocName());

        }
    }
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我在 UI 上还有一个功能,用于显示文档的缩略图 - 对于 PDF,我使用 PDFBox 提取第一页并将其转换为 PNG 图像并在p:graphicImage. 我观察到,在这张图片中,数字签名显示得很好!

我使用的是 SpringBoot + PF 6.2 + JoinFaces

Mel*_*are 5

如果您需要显示带数字签名的 PDF,PDF.js 目前不支持,该票证自 2012 年起就已开放。

请参阅: https: //github.com/mozilla/pdf.js/issues/1076

我建议您使用这些免费且在浏览器中运行的服务来显示带签名的 PDF: https ://verify.ink/