Hi,

This demo might help:
http://click.avoka.com/click-examples/general/excel-export.htm

regards

Bob

On 2013/05/16 17:24, [email protected] wrote:
I am using DynamicReports (based on JasperReports) for creating PDF reports in 
Apache Click.  Some users want to display the PDF report in a web browser and 
other users want to display the PDF report in the PDF document viewer (e.g., 
Adobe Acrobat).  Using the following code the PDF report displays correctly in 
the browser when using IE, Chrome, and Firefox.  However, for the users that 
have their browsers configured to show PDFs outside of the browser, the PDF 
report only displays in the PDF document viewer when using IE.  Chrome and 
Firefox download a file with the wrong file extension (user-1.htm instead of 
user-1.pdf).

What is the proper code for getting the PDF report to display correctly both in 
a web browser or outside of the web browser depending on how the client has 
their browser configured to display PDFs?

///////////////////
         private static final long serialVersionUID = 1L;

         public User1Page() {
                 Submit reportButton = new Submit("runReport", " Report ", this, 
"onReportClick");
                 form1.add(reportButton);
         }

         public void renderPdf() throws ServletException, IOException {
                 HttpServletResponse response = getContext().getResponse();
response.setContentType("application/pdf");

                 OutputStream out = response.getOutputStream();

                 try {
                         report()
                         // ...

                         .toPdf(out);

                 } catch (DRException e) {
                   throw new ServletException(e);
                 }
                 out.close();
         }

         public boolean onReportClick() {
                 try {
                         renderPdf();
                 } catch (Exception e) {
                         e.printStackTrace();
                 }

                 return true;
         }
///////////////

Thank you and keep up the good work.  Apache Click is a fantastic framework.

Thank you,
Paul
____________________________________________________________
Woman is 60 But Looks 25
Mom publishes simple facelift trick that angered doctors...
http://thirdpartyoffers.netzero.net/TGL3231/5194fa5fc3c407a5f3a9cst03duc

Reply via email to