Is there any way or function that IReport Designer allows me to print my server date without any Java class when I print the document.
I have a problem when displaying one of my reports in a Jpanel of my graphical interface.
It is worth mentioning that the report that gives me problems, I can see it on my machine even after opening it in the interface of my application that is already generated, that is, I open my app.jar
, I click on a jButton
to generate the report, called "Caratula" and it shows it to me, but when I run my application on another machine and click on jButton
it, said report is not shown in Jpanel
it and it does not show me an error, it just stays blank Jpanel
and does not even show the menus above where it can be done zoom etc
This is the generated report:
The code I use in the ActionPerformed of the JButton is the following:
try {
//Aquí obtengo la fecha que uso en uno de los parametros...
Calendar cal = dateChooserComboFechaCaratula.getSelectedDate();
Date date = cal.getTime();
SimpleDateFormat formatFechaSQL = new SimpleDateFormat("yyyy-MM-dd");
String fechaFin = formatFechaSQL.format(date);
String dir_current = System.getProperty("user.dir") ;
String file_report = dir_current+"/Reportes/Caratula/Cartula_general.jasper";
String dir_mañana = dir_current+"/Reportes/Caratula/caratula_mañana/";
String dir_tarde = dir_current+"/Reportes/Caratula/caratula_tarde/";
String noche_1 = dir_current+"/Reportes/Caratula/Caratula_noche_1/";
String dir = dir_current+"/Reportes/Caratula/";
String noche_2 = dir_current+"/Reportes/Caratula/Caratula_noche_2/";
String gasolin = dir_current+"/Reportes/Caratula/gasolinera/";
File fichero = new File(file_report);
JasperReport jr;
jr = (JasperReport) JRLoader.loadObject(fichero);
Map parameters = new HashMap();
parameters.put("SUBREPORT_DIR_MAÑANA",dir_mañana);
parameters.put("SUBREPORT_DIR_TARDE",dir_tarde);
parameters.put("SUBREPORT_DIR_NOCHE_1",noche_1);
parameters.put("SUBREPORT_DIR",dir);
parameters.put("SUBREPORT_DIR_NOCHE_2",noche_2);
parameters.put("SUBREPORT_DIR_GASOLINERA",gasolin);
parameters.put("fecha", fechaFin);
JasperPrint jasperprint = JasperFillManager.fillReport(jr,parameters, DbConexion.getConnection());//new JREmptyDataSource()
JasperViewer jviewer = new JasperViewer(jasperprint);
refrescar_Ventana();
jPanel2.removeAll();
jPanel2.add(jviewer.getContentPane(), BorderLayout.CENTER);
} catch (JRException ex) {
System.out.println(ex);
JOptionPane.showMessageDialog(JIFCaratula.this,ex, "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(JIFCaratula.this, "No fue posible generar el reporte, revise que las rutas sean las adecuadas", "Error", JOptionPane.ERROR_MESSAGE);
}
I have a big problem:
Context:
I have a web application with primefaces 6.0 and ireport 4.0 where I print several reports in pdf format, all of them work correctly.
Problem:
I need a report to be printed directly on the printer ( the name of the printer must be parameterized, since it is not the default ) of the client, as the report is executed on the server when reading the installed printers, it does not find anything, since on the server ( Linux Red Hat ) there is no printer installed.
I attach the code that sends to the default printer, but do not forget that I want to send it to another printer:
String ctxPath = getServletContext().getRealPath("/");
connection = utilServiceDelegate.getDataSource()
.getConnection();
HttpServletResponse response = (HttpServletResponse) FacesContext
.getCurrentInstance().getExternalContext()
.getResponse();
JasperPrint jasperPrint = JasperFillManager.fillReport(ctxPath+ rutaReporte, parameters,
connection);
JasperPrintManager.printReport(jasperPrint, false);
If anyone has solved this with ireport 4 or lower, I'd really appreciate it.
Thanks.