freecouch
freecouch

Reputation: 233

Render PDF in browser using Primefaces 3.4

Is it possible render a PDF object using Primeface 3.4 and DefaultStreamedContent? This used to work for us in Primefaces 2.2:

Backing Bean:

   streamedDoc = new DefaultStreamedContent(pdfStream, "application/pdf");
...
 public StreamedContent getStreamedDoc() {
    return streamedDoc;
 }

view:

<object id="embeddedPDF"
       data="?primefacesDynamicContent=confirmForm.streamedDoc#toolbar=0?docId=456"
       type="application/pdf"
       width="100%"
       height="1610px"/>

But after upgrading to 3.4, the PDF doesn't get rendered. We don't get an exception. We simply get this Abode Reader error in the browser:

Adobe Reader could not open 'A9RE0BF.tmp' because it is either not a supported file type or because the file has been damaged. (for example, it was sent as an email attachment and wasn't correctly encoded)."

Any ideas?

Upvotes: 0

Views: 7885

Answers (1)

dcalap
dcalap

Reputation: 1072

What about using the primefaces lightbox and the media components?

http://www.primefaces.org/showcase/ui/multimedia/media.xhtml

http://www.primefaces.org/showcase/ui/overlay/lightBox.xhtml

You can see the PDF inside the lightBox, I think it's more elegant.

Anyway just with the media one you can solve your problem I guess.

Regards.

Upvotes: 3

Related Questions