Using <p:media value="#{commonManagedBean.pdfStreamContent}" player="pdf"/
> with streamed content.
Noticed that the PDF viewer's title shows "dynamiccontent.properties" while the PDF is loading and then changes to the actual title of the PDF.
Also, on downloading the PDF from the PDF viewer, the file name is displayed as "dynamiccontent.pdf" in the browser.
public DefaultStreamedContent getPdfStreamContent (){ super.setPdfFile(new DefaultStreamedContent()); byte[] pdfFile=getPdfList().get(0); if(null!=pdfFile){ super.getPdfFile().setStream(new ByteArrayInputStream(pdfFile)); super.getPdfFile().setContentType("application/pdf"); super.getPdfFile().setName("document.pdf"); return super.getPdfFile(); } }
Generated HTML code of <p:media>
component:
<object width="950" height="455" data="/warcom/javax.faces.resource/dynamiccontent.properties.jsf?ln=primefaces&v=6.0&pfdrid=d6762c48-9cfd-4596-b955-b1075967f062&pfdrt=sc&pfdrid_c=true" type="application/pdf"> </object>
I have tried below but this does not seem to work:
new DefaultStreamedContent(getData(), "application/pdf", "test.pdf");
How to change the file name to other name ?
Using PrimeFaces 6.0
0 comments:
Post a Comment