This content has been marked as final.
Show 3 replies
-
1. Re: a4j:mediaOutput to display a PDF
sriramsudheer Mar 16, 2008 8:47 PM (in response to marinew)Hi marine,
I am also stuck at the same point and if you able to find a solution please help me by posting your answer and where went wrong. -
2. Re: a4j:mediaOutput to display a PDF
adam_p_wells Jun 11, 2008 9:49 PM (in response to marinew)I had the same problem, and a quick look around this forum has no success stories.
I found a solution http://www.seamframework.org/Community/DirectPDFServing#comment8459 that works very well for me.
I use this in pages.xml<page view-id="/secure/billing/pdfInvoice.xhtml" action="#{billingDataProvider.outputPdf}"> <param name="pdfInvoiceUid" value="#{billingDataProvider.pdfInvoiceUid}"/> </page>
and my bean has this method:public void outputPdf() { PDFInvoiceDTO invoice = pdfInvoicingService.getInvoice(pdfInvoiceUid); final HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", " attachment; filename=invoice.pdf"); try { response.getOutputStream().write(invoice.getInvoiceDocument()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } facesContext.responseComplete(); }
Hope this helps... -
3. Re: a4j:mediaOutput to display a PDF
marinew Jun 17, 2008 11:19 AM (in response to marinew)Thanks for your reply. But If I understand well your solution, it renders the PDF file directly in the navigator, and not inside an HTML "object", inside a webpage with others HTML elements.
Here is an example of how I would like to display the PDF file :<html> <head>(...)</head> <body> Here is the resulting document : <object data="myDoc.pdf" style="width:300px; height:300px;" type="application/pdf"> </object> I can write some text in my page, around the object that display the PDF file.... </body> </html>