I need to print one jasperreport,
Today I use this code:
try {
Resource resource = resourceLoader.getResource(resourceLoader.CLASSPATH_URL_PREFIX + "/static/relatorios/ReciboMovimentacaoMultiPedidos.jrxml");
JasperDesign jasperDesign = JRXmlLoader.load(resource.getInputStream());
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
Map<String,Object> parametros = new HashMap<>();
parametros.put("idMovimentacao",idMovimentacao);
StreamResource.StreamSource source = new StreamResource.StreamSource() {
public InputStream getStream() {
byte[] b = null;
try{
b = JasperRunManager.runReportToPdf(jasperReport,parametros, jdbcTemplate.getDataSource().getConnection());
} catch (Exception e) {
e.printStackTrace();
}
return new ByteArrayInputStream(b);
}
};
StreamResource resourcesReport = new StreamResource(source, "ServicosPorPeriodo" + System.currentTimeMillis() + ".pdf");
BrowserWindowOpener opener = new BrowserWindowOpener(resourcesReport);
Button downloadButton = new Button(FontAwesome.DOWNLOAD);
panelDownload.addComponent(downloadButton);
panelDownload.setComponentAlignment(downloadButton, Alignment.MIDDLE_RIGHT);
opener.extend(downloadButton);
}catch (Exception e){
e.printStackTrace();
}
But I dont want to show another button to my user click in this button to open a new window, and then click the print button
I want to send to print after finish to generate te rel.
it`s possible?? how??
tks