2

I have a multi-format document viewer, in which, for displaying PDFs, I use PF Extension's p:documentViewer component. The backing bean that supplies the StreamedContent of the PDF is phase rendered and is working as expected. However, though the PDF itself gets rendered fine, the viewer doesn't display the digital signatures in it. Do I need to add any extra configurations to the p:documentViewer while using it? Here is my usage of it:

<pe:documentViewer id="pdfVw" height="600" width="800" value="#{viewerController4.pdfDocumentStream}">                                           
    <f:param name="id" value="#{viewerController4.currentDocId}" /> 
</pe:documentViewer> 

The backing bean method serving the content of the PDF:

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());

        }
    }

Incidentally, I also have a feature on the UI, to display thumbnails of documents -- in which, for PDFs, I extract the first page using PDFBox and convert that into a PNG image and display within a p:graphicImage. I observe, that in this image, the digital signature is displayed fine!

I'm on SpringBoot + PF 6.2 + JoinFaces

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Tatha
  • 131
  • 1
  • 13
  • PrimeFaces extensions is using pdf.js under the hood. Check if that has options for this. – Kukeltje Apr 21 '20 at 18:10
  • I did not check all links but this search helps: https://www.google.com/search?client=firefox-b-d&q=show+signature+pdf.js – Kukeltje Apr 21 '20 at 18:38
  • You can read this issue about the open ticket in PDF.JS https://github.com/mozilla/pdf.js/issues/1076 However it appears there is a line i can comment to make the signature appear! Can you please submit a request on our GitHub issues page here: https://github.com/primefaces-extensions/primefaces-extensions.github.com/issues – Melloware Apr 22 '20 at 10:32
  • I opened this ticket: https://github.com/primefaces-extensions/primefaces-extensions.github.com/issues/787 Can you comment there? Also maybe put an example screenshot of your digital signture? – Melloware Apr 22 '20 at 13:08
  • Actually i just tried it and it doesn't work. – Melloware Apr 22 '20 at 13:41

1 Answers1

5

If you need to display PDF with digital signatures PDF.js does not support it currently and the ticket has been open since 2012.

See: https://github.com/mozilla/pdf.js/issues/1076

I suggest you use these service which is free and runs in the browser to show PDF's with signatures: https://verify.ink/

Melloware
  • 10,435
  • 2
  • 32
  • 62
  • I was wondering if `p:media` could be an alternate option. I tried with a few signed docs. It displays the signatures fine...and the messages that come up on the viewer also seem to indicate that it tries to verify the signature as well, which is a plus. – Tatha Apr 24 '20 at 09:42
  • About https://verify.ink/ , the license seems to be restrictive for any distribution of code that uses verify.ink (in my case, it's code developed for a client). Also, from the example usages, I'm assuming the doc would actually get transferred over to verify.ink...no? – Tatha Apr 24 '20 at 09:46
  • The worry that I have with `p:media` is that, the look-n-feel of the viewer is varying between IE and Chrome, but I suppose that can be fixed with CSS. – Tatha Apr 24 '20 at 09:52
  • Yeah p:media might be your fastest way to go. – Melloware Apr 24 '20 at 11:29
  • 1
    Verify.ink happens all client-side, the document is not sent to the server unless you enable integration with Hancock, the signing product it is integrated with. As for your license concern, Verify is not OSS but it is available free for use. In full disclosure, my company makes both Hancock and Verify. – rmhrisk Apr 29 '20 at 18:07
  • p:media still does not solve the problem here. I am using primefaces version 10.0.0 – brlaranjeira Apr 19 '21 at 02:55
  • 1
    @brlaranjeira p:media will be going away in the future as well. Its been Marked deprecated by PrimeTek. – Melloware Apr 19 '21 at 12:05
  • Didn't notice that. Should I just use , in this case? – brlaranjeira Apr 19 '21 at 12:28
  • Not sure what to use but the PF Media component is using the `` tag under the covers for PDF : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object – Melloware Apr 19 '21 at 12:32
  • @Melloware Can verify.ink use a3, hardware certificates? I know you guys, at Peculiar, have the Fortify to work with this kind of certificates. Are these solutions related? – Celso Marigo Jr Mar 14 '22 at 16:11
  • Probably a question for verify.ink as I don;t work for them. Maybe send them a support email asking them. – Melloware Mar 14 '22 at 21:32