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.
I managed to fix it.
In case nothing changes in my code, I had to install a samba client on the linux server, and in this way be able to see the shared printer on the windows network.
In this way the application server can detect the printers that the server has configured:
I leave you the code to read the printers that the server can see and send to print to one of them: