Advertisement
andersonalmada2

Untitled

Aug 26th, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1.  
  2. @Service
  3. public class ReportSolicitation {
  4.  
  5.     private JasperReport solicitationReport;
  6.  
  7.     @PostConstruct
  8.     private void initReport() {
  9.         try {
  10.             solicitationReport = JasperCompileManager
  11.                     .compileReport(FilesLoader.getInputStreamFromPath("/static-files/record.jrxml"));
  12.         } catch (Exception e) {
  13.  
  14.  
  15.         }
  16.     }
  17.  
  18.     public byte[] getReport() {
  19.         // dynamic parameters required for report
  20.         Map<String, Object> empParams = new HashMap<String, Object>();
  21.         empParams.put("Field", "Value");
  22.  
  23.         byte[] bytesFile;
  24.  
  25.         try {
  26.             JasperPrint empReport = JasperFillManager.fillReport(solicitationReport, empParams,
  27.                     new JREmptyDataSource());
  28.             bytesFile = JasperExportManager.exportReportToPdf(empReport);
  29.  
  30.         } catch (JRException e) {
  31.  
  32.         }
  33.  
  34.         return bytesFile;
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement