Custom JasperReportsTiffView to export tiff reports

时间:2018-02-01 18:03:02

标签: java spring spring-boot jasper-reports

I've a Spring Boot, Spring Data REST, Spring MVC application. I'm using Jasper report 6.5 to create reports. I'm exposing my REST endpoints to a Angular application.

I created and endpoing that export a PDF and I would need another endpoint that export the same report in tiff. I'm using JasperReportsViewResolver in order to take advantage of Spring integration. I'm using method 4 shown here.

So I've a properties file with something like:

DepositReceiptPdfView-IT.(class)=org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView
DepositReceiptPdfView-IT.url=classpath:/reports/workflows/DepositReceipt-IT.jrxml

and my endpoint is something like:

@GetMapping(path = "/depositReceipts/{id}/export")
    public ModelAndView exportPdf(@PathVariable("id") Long id, HttpServletRequest request, Locale locale) throws Exception {
        DepositReceipt depositReceipt = depositReceiptRepository.findOne(id);
        if (depositReceipt != null) {
            ModelMap model = new ModelMap();
            model.addAttribute("datasource", new JREmptyDataSource(1));
            model.addAttribute("model", depositReceipt);

            return new ModelAndView("DepositReceiptPdfView-IT", model);
        } else {
            throw new ResourceNotFoundException();
        }
    }

And I like very much this way to do. It is very clean. I was looking for a org.springframework.web.servlet.view.jasperreports.JasperReportsTiffView but unfortunately there isn't.

Is there a way to accomplish my needs using this way of proceed?

0 个答案:

没有答案