daust / JasperReportsIntegration

JasperReportsIntegration provides an interface to use the JasperReports reporting engine in an Oracle database application, specifically with Oracle Application Express (Oracle APEX).
BSD 3-Clause "New" or "Revised" License
56 stars 26 forks source link

Direct Printing is not working #121

Open saint-ago opened 1 year ago

saint-ago commented 1 year ago

Hello daust.

I have an issue with the direct printing in the 2.8.1 version. I generate a report with the flags: _printIsEnabled=true and _printPrinterName=PRINTER_NAME.

Everything is running ok, the report is generated in the web browser, but it doesn't send the report to the print declared in the flags. The printer is in the list of the JasperReportsIntegration - Printer Diagnostics.

I searched for more infomation in the JasperReportsIntegration.log and I saw these last lines:

08:13:01 [INFO] jasper.webapp.ReportWrapper.service - *** servlet /report START
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters - Request parameters:
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _repName: DTEMICR_0037
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _rep_Format: docx
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _dataSource: $P{DATA_SOURCE}
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printIsEnabled: true
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printPrinterName: ${PRINTER_NAME}
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_INM_ID: ${P_INM_ID}
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_PRO_ID: $P{P_PPR_PRO_ID}
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_PRO_TOR_ID: $P{P_PPR_PRO_TOR_ID}
08:13:01 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_NRO_PASO: $P{P_PPR_NRO_PASO}
08:13:01 [INFO] jasper.webapp.ReportWrapper.service - using report file: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\DTEMICR_0037.jasper
08:13:01 [INFO] oc.db.ConnectionUtility.getConnection - successfully connected to jdbc:oracle:thin:@URL_CONNECTION:SID with user: USER
08:13:01 [INFO] oc.print.PrinterUtilities.print - lookup printer by name: ${PRINTER_NAME}

I replaced the original values in the log for security reasons. I hope you can understand.

What can it be? I am missing some parameters in the url?

More information:

Thanks for advanced.

daust commented 1 year ago

Hi Santiago,

Let me know whether one of these suggestions work. Thank you ~Dietmar.

saint-ago commented 1 year ago

Hi Daust

Yes, I changed the isEnabled setting to true.

#====================================================================
# Direct printing
#====================================================================
[directPrinting]
isEnabled=true

# for debugging purposes does it make sense to display the 
# print dialog ON THE SERVER before printing. You can even cancel the 
# request through the print dialog
# DON'T do that in production (displayPrintDialog=true)!!!
displayPrintDialog=true

I'm working in a development enviroment, so I set the displayPrintingDialog to true.

Now I'm trying the TRACE level to see more information in the log file.

Thanks a lot for the fast reply!

daust commented 1 year ago

Thanks a lot for the fast reply! You were just lucky ;) I finally finished up so many things that kept me busy. Now I can spend some more time on this project :).

saint-ago commented 1 year ago

Hi again Daust!

This is the log file with the level trace :

09:55:12 [INFO] jasper.webapp.ReportWrapper.service - *** servlet /report START
09:55:12 [TRACE] jasper.webapp.URLCallInterface.<init> - Enter
09:55:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters - Request parameters:
09:55:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _repName: DTEMICR_0037
09:55:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _rep_Format: pdf
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _dataSource: ${DATA_SOURCE}
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printIsEnabled: true
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printPrinterName: ${PRINTER_NAME}
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printerJobName: DTEMICR_0037
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_INM_ID: ${P_INM_ID}
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_PRO_ID: ${P_PPR_PRO_ID}
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_PRO_TOR_ID: ${P_PPR_PRO_TOR_ID} 
09:55:13 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_NRO_PASO: ${P_PPR_NRO_PASO}
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> - URL parameters including defaults:
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    dataSource=${DATA_SOURCE}
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repName=DTEMICR_0037
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repFormat=pdf
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repLocale=de_DE
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repEncoding=UTF-8
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repTimeZone=America/Buenos_Aires
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    printUsePrinter=true
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    printPrinterName=${PRINTER_NAME}
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> -    printCopies=1
09:55:13 [DEBUG] jasper.webapp.URLCallInterface.<init> - input values asserted
09:55:13 [TRACE] jasper.webapp.URLCallInterface.<init> - Exit
09:55:13 [DEBUG] oc.jasper.ReportUtilities.compileJRXMLIfNecessary - search for report DTEMICR_0037 in reportsPath: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports
09:55:13 [TRACE] oc.jasper.ReportUtilities.compileJRXMLIfNecessary -   test for report: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\DTEMICR_0037.jrxml => true
09:55:13 [TRACE] oc.jasper.ReportUtilities.compileJRXMLIfNecessary -   test for report: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\DTEMICR_0037.jasper => true
09:55:13 [DEBUG] oc.jasper.ReportUtilities.getReportDefinitionFile - search for report DTEMICR_0037 in reportsPath: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports
09:55:13 [TRACE] oc.jasper.ReportUtilities.getReportDefinitionFile -   test for report: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\DTEMICR_0037.jasper
09:55:13 [INFO] jasper.webapp.ReportWrapper.service - using report file: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\DTEMICR_0037.jasper
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - set parameter BaseDir:C:\jri-2.8.1-jasper-6.18.1\conf\..\reports
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - set parameter SUBREPORT_DIR:C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - set parameter REPORT_LOCALE:de_DE
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - set report timezone:America/Buenos_Aires
09:55:13 [TRACE] oc.db.ConnectionUtility.getConnection - lookup dataSource:${DATA_SOURCE}
09:55:13 [DEBUG] oc.db.ConnectionUtility.getConnection - use JDBC to lookup dataSource:${DATA_SOURCE}
09:55:13 [TRACE] oc.db.ConnectionUtility.getConnection - retrieve connectionPoolDataSource from HashMap first
09:55:13 [DEBUG] oc.db.ConnectionUtility.getConnection - initial pool size: 5
09:55:13 [DEBUG] oc.db.ConnectionUtility.getConnection - min pool size: 5
09:55:13 [DEBUG] oc.db.ConnectionUtility.getConnection - max pool size: 50
09:55:13 [INFO] oc.db.ConnectionUtility.getConnection - successfully connected to jdbc:oracle:thin:@URL_CONNECTION:SID with user: USER
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - fill report
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - net.sf.jasperreports.jdbc.fetch.size=0
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - set contentType=application/pdf
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - export report
09:55:13 [DEBUG] jasper.webapp.ReportWrapper.service - user wants to use printer directly ...  
09:55:13 [TRACE] jasper.webapp.ReportWrapper.service - printing is enabled in the configuration file
09:55:13 [INFO] oc.print.PrinterUtilities.print - lookup printer by name: ${PRINTER_NAME}
09:55:13 [DEBUG] oc.print.PrinterUtilities.print - setPrintService()
09:55:13 [DEBUG] oc.print.PrinterUtilities.print - lookupMedia(null)

And this is the log file with the level debug :

09:35:08 [INFO] jasper.webapp.AppConfig.initialize - *****************************************************
09:35:08 [INFO] jasper.webapp.AppConfig.initialize - *** Initialize JasperReportsIntegration (jri) - END
09:35:08 [INFO] jasper.webapp.AppConfig.initialize - *****************************************************
09:35:12 [INFO] jasper.webapp.ReportWrapper.service - *** servlet /report START
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters - Request parameters:
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _repName: DTEMICR_0037
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _rep_Format: pdf
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _dataSource: ${DATA_SOURCE}
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printIsEnabled: true
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printPrinterName: ${PRINTER_NAME}
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    _printerJobName: DTEMICR_0037
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_INM_ID: ${P_INM_ID}
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_PRO_ID: ${P_PPR_PRO_ID}
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_PRO_TOR_ID: ${P_PPR_PRO_TOR_ID} 
09:35:12 [INFO] oc.servlet.ServletUtilities.logRequestParameters -    P_PPR_NRO_PASO: ${P_PPR_NRO_PASO}
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> - URL parameters including defaults:
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    dataSource=MANANTIAL_RESGUARDO
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repName=DTEMICR_0037
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repFormat=pdf
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repLocale=de_DE
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repEncoding=UTF-8
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    repTimeZone=America/Buenos_Aires
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    printUsePrinter=true
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    printPrinterName=${PRINTER_NAME}
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> -    printCopies=1
09:35:12 [DEBUG] jasper.webapp.URLCallInterface.<init> - input values asserted
09:35:12 [DEBUG] oc.jasper.ReportUtilities.compileJRXMLIfNecessary - search for report DTEMICR_0037 in reportsPath: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports
09:35:12 [DEBUG] oc.jasper.ReportUtilities.getReportDefinitionFile - search for report DTEMICR_0037 in reportsPath: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports
09:35:12 [INFO] jasper.webapp.ReportWrapper.service - using report file: C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\DTEMICR_0037.jasper
09:35:12 [DEBUG] jasper.webapp.ReportWrapper.service - set parameter BaseDir:C:\jri-2.8.1-jasper-6.18.1\conf\..\reports
09:35:12 [DEBUG] jasper.webapp.ReportWrapper.service - set parameter SUBREPORT_DIR:C:\jri-2.8.1-jasper-6.18.1\conf\..\reports\
09:35:12 [DEBUG] jasper.webapp.ReportWrapper.service - set parameter REPORT_LOCALE:de_DE
09:35:12 [DEBUG] jasper.webapp.ReportWrapper.service - set report timezone:America/Buenos_Aires
09:35:12 [DEBUG] oc.db.ConnectionUtility.getConnection - use JDBC to lookup dataSource:${DATA_SOURCE}
09:35:13 [DEBUG] oc.db.ConnectionUtility.getConnection - initial pool size: 5
09:35:13 [DEBUG] oc.db.ConnectionUtility.getConnection - min pool size: 5
09:35:13 [DEBUG] oc.db.ConnectionUtility.getConnection - max pool size: 50
09:35:13 [INFO] oc.db.ConnectionUtility.getConnection - successfully connected to jdbc:oracle:thin:@URL_CONNECTION:SID with user: USER
09:35:13 [DEBUG] jasper.webapp.ReportWrapper.service - fill report
09:35:16 [DEBUG] jasper.webapp.ReportWrapper.service - net.sf.jasperreports.jdbc.fetch.size=0
09:35:16 [DEBUG] jasper.webapp.ReportWrapper.service - set contentType=application/pdf
09:35:16 [DEBUG] jasper.webapp.ReportWrapper.service - export report
09:35:17 [DEBUG] jasper.webapp.ReportWrapper.service - user wants to use printer directly ...  
09:35:17 [INFO] oc.print.PrinterUtilities.print - lookup printer by name: ${PRINTER_NAME}
09:35:17 [DEBUG] oc.print.PrinterUtilities.print - setPrintService()
09:35:18 [DEBUG] oc.print.PrinterUtilities.print - lookupMedia(null)

Now I'm thinking about the permissions. It could be that? Because I work in a company and the printer is connected with my PC by URl, I mean, the printer name is an URl.

Well, I'm going to talk with the security area about the permissions and if the problem is not the permissions, I'm going to install the new version like you said.

Thanks a lot Daust! I'm very lucky to catch you with some free time :D

Santiago.

daust commented 1 year ago

Thank you for providing this feedback and log file. The printer is installed locally on the same machine as Tomcat is running, right? It can be a network printer but is has to be installed locally, so that it is visible to the Java Print Service API.

Best of luck.

najeebalikhel commented 5 months ago

Hello I have your version of jri 2.10 but the problem is that if you have printer in local system and you are passing printer name as local system then it will not work unless server printer in server it prints in server I think directPrint is for its server printer not the printer in local system
if I have http://liveIp/jri/reports?blalalalalalla it will not work for local system printer is it bad.

daust commented 2 months ago

Hi @najeebalikhel,

sorry for the late reply. Did you figure it out? Not sure, I understand your question properly.

The print support is designed for printouts on the server. Due to security constraints, it is not possible to print on the user's machine. You would have to use the name under which the printer is registered on the server on which Tomcat is installed.

Best, Dietmar.

najeebalikhel commented 1 month ago

@daust I have still issue kindly provide me your whatsapp no to call and discuss with you

daust commented 4 weeks ago

Hi @najeebalikhel ,

please send me an email to dietmar.aust at gmail.com we can talk it further from there. Then I can share my phone number.

But, really, there is currently no way to automate the printing to a local printer from a user's perspective. He can always click on "print" when the pdf is displayed.

The only way to print automatically is to a printer that is mapped to the server where JasperReportsIntegration is running.

This and next week I am busy on a trip to Chicago and Cologne. On the 11th I will be on Madeira for a few months. Before that I will not be available.

Best, Dietmar.