1
In my system a txt file is imported read and printed on the standard printer, the report is done in ireport and I use the printPage method of Jasperprintmanager to print on the standard printer, according to the code below:
public void ImprimirBilhete(java.util.List lista) {
/*String caminhoRelJasper = "/com/bilhete/relatorio/bilheteteste.jasper";
InputStream relJasper = getClass().getResourceAsStream(caminhoRelJasper);*/
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(lista);
Map parametros = new HashMap();
JasperPrint impressao = null;
//parametros.put("CAMINHO_IMAGEM", System.getProperty("user.dir") + "\\imagem\\logocidade.jpg");
try {
//parametros.put("CAMINHO_IMAGEM", System.getProperty("user.dir") + "\\imprimir\\barra.jpeg");
//*para funcionario abrir os relatorio dentro do pacote tem q configurar o parametros no ireport como InputScream
InputStream caminhoImagemBrasao = getClass().getResourceAsStream("/com/bilhete/imagens/barra.jpeg");
parametros.put("CAMINHO_IMAGEM", caminhoImagemBrasao);
InputStream is = getClass().getResourceAsStream("/com/bilhete/relatorio/bilheteteste.jasper");
impressao = JasperFillManager.fillReport(is, parametros, ds);
//impressao = JasperFillManager.fillReport(relJasper, parametros, ds);
//JasperViewer viewer = new JasperViewer(impressao, true);
//*aparece o relatorio na tela
//*JasperViewer.viewReport(impressao, false);
//viewer.setVisible(true);
//manda direto pra impressora padrao
JasperPrintManager.printPage(impressao, 0, false);
} catch (JRException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e, "Erro Ireport", JOptionPane.INFORMATION_MESSAGE);
}
}
I wanted to know if there is any method in Jasperprintmanager that sends the printing to a specific printer, such as a printer with the name "such" or some USB port.
Thanks I’ll take a look
– jallisson jallis oliveira band
@jallissonjallisoliveiraband, I adjusted the responsta, I believe with that already solve your problem.
– Gilvan André
valeu helped me a lot I used the private void Printreporttoprinter(Jasperprint jp) throws Jrexception { from the example.
– jallisson jallis oliveira band
Whoa, that’s great. Thanks!
– Gilvan André