Do you want to display the PDF on screen, or provide a PDF download so that the file could be opened in Acrobat Reader (or PDF viewer of your choice)?
On Tue, Dec 4, 2012 at 11:06 AM, appwicket <wwx....@gmail.com> wrote: > Hi all, > I have been trying all the ways to display PDF through wicket. > I have my pdf resource in Byte[]. > I tried the following methods in my AjaxButton's onSubmit method: > 1. this gives me exception: > Header was already written to response! > Wicket.Ajax.Call.failure: Error while parsing response: Error: Invalid XML: > %PDF-1.4 > > WebResponse r = (WebResponse)getRequestCycle().getResponse(); > r.setContentType("application/pdf"); > r.setHeader("Content-Disposition", "inline; filename=\"data.pdf\""); > r.write(reportService.generatePDF()); > getRequestCycle().setResponsePage(DownloadPopup.class); > ------------- > 2.this gives me exception: > Wicket.Ajax.Call.failure: Error while parsing response: Error: Invalid XML: > %PDF-1.4 > > ByteArrayResource bar = new ByteArrayResource("application/pdf", > reportService.generatePDF()); > RequestCycle.get().scheduleRequestHandlerAfterCurrent(new > ResourceRequestHandler(bar, null)); > ------------- > 3. I also tried example from AJAX update and file download in one blow > > https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html > < > https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html > > > but Im not able to convert Byte array to IResourceStream. > > Anyone knows how to do this? > > appreciated! > > > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/How-to-display-PDF-in-wicket-6-0-tp4654471.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >