BrightSide Workbench Full Report + Source Code
org.turro.pdf.GeneratePDF Class Reference

Static Public Member Functions

static void writeAsResponse (HttpServletResponse response, String jasperFile, Collection collection, Map parameters)
 
static void exportToStream (OutputStream out, String jasperFile, Collection collection, Map parameters)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 42 of file GeneratePDF.java.

Member Function Documentation

◆ exportToStream()

static void org.turro.pdf.GeneratePDF.exportToStream ( OutputStream  out,
String  jasperFile,
Collection  collection,
Map  parameters 
)
static

Definition at line 67 of file GeneratePDF.java.

67  {
68  try {
69  JRDataSource dataSource = new JRBeanCollectionDataSource(collection);
70  JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFile, parameters, dataSource);
71  JasperExportManager.exportReportToPdfStream(jasperPrint, out);
72  } catch (JRException ex) {
73  Logger.getLogger(GeneratePDF.class.getName()).log(Level.SEVERE, null, ex);
74  }
75  }
Here is the caller graph for this function:

◆ writeAsResponse()

static void org.turro.pdf.GeneratePDF.writeAsResponse ( HttpServletResponse  response,
String  jasperFile,
Collection  collection,
Map  parameters 
)
static

Definition at line 44 of file GeneratePDF.java.

44  {
45  ServletOutputStream output = null;
46  try {
47  response.setContentType("application/pdf");
48  response.setHeader("pragma", "no-cache");
49  response.setHeader("Cache-control", "no-cache, no-store, must-revalidate");
50  response.setHeader("Expires", "01 Apr 1995 01:10:10 GMT");
51  response.setHeader( "Content-Disposition", "filename=" + FileUtil.getBaseName(new File(jasperFile)) +".pdf" );
52 
53  output = response.getOutputStream();
54  exportToStream(output, jasperFile, collection, parameters);
55  output.flush();
56  } catch (IOException ex) {
57  Logger.getLogger(GeneratePDF.class.getName()).log(Level.SEVERE, null, ex);
58  } finally {
59  try {
60  output.close();
61  } catch (IOException ex) {
62  Logger.getLogger(GeneratePDF.class.getName()).log(Level.SEVERE, null, ex);
63  }
64  }
65  }
static void exportToStream(OutputStream out, String jasperFile, Collection collection, Map parameters)
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: