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
55 stars 23 forks source link

Asynchrone abarbeitung von xlib_jasperreports.get_report / Asynchronous processing of xlib_jasperreports.get_report #141

Open agrigorjan opened 4 months ago

agrigorjan commented 4 months ago

Hallo Herr Aust, wir nutzen Ihre Lösung zur 99%, um eine PDF-Datei zu erstellen, welche auf dem Server gespeichert und anschließend verarbeitet wird. Zum Verarbeiten der PDF-Datei (z.B. Drucken auf dem Drucker XYZ) nutzen wird pro PDF-Datei eine Text-Datei. Diese Text-Datei heißt genauso wie die PDF-Datei. Lautet der Name der PDF-Datei z.B. Test_1234.pdf, dann ist der Name der Textdatei Test_1234.txt. Die Textdatei beinhaltet DOS-Befehle, um z.B. die PDF-Datei auf einem Netztwerkdrucker zu drucken, per E-Mail zu versenden, in ein Verzeichnis zu verschieben usw. Am Ende der Textdatei wird in 99% der Fällen der Befehl zum Löschen der beiden Dateien (PDF und TXT), wie für den Beispiel „DEL Test_1234.*“ verwendet (wir arbeiten in Windows-Welt).

Zum Erstellen der PDF-Datei nutzen wir xlib_jasperreports.get_report(p_rep_name => p_rep_name, p_rep_format => XLIB_JASPERREPORTS.C_REP_FORMAT_PDF, p_data_source => p_data_source, p_rep_locale => 'de-DE', p_rep_encoding => 'UTF-8', p_additional_params => p_additional_params, p_print_is_enabled => FALSE, p_print_printer_name => 'Dummy', p_print_media => 'iso-a4', p_print_copies => 1, p_print_duplex => FALSE, p_print_collate => FALSE, p_save_is_enabled => TRUE, p_save_filename => 'C:/PrintPDF/' || v_filename || '.pdf', p_out_blob => v_blob, p_out_mime_type => v_mime_type );

In PL/SQL wird jedoch das Erstellen der PDF-Datei asynchron durchgeführt. Das bedeutet, bei großen PDF-Datei ist die Datei noch nicht fertiggeschrieben bzw. noch nicht geschlossen und im PL/SQL werden bereits weitere Funktionen durchgeführt. Das führt in unserem konkreten Beispiel dazu, dass z.B. „Drucken“-Befehl übersprungen und das „Löschen“-Befehl ausgeführt wird. Somit „verschwindet“ die Textdatei und die PDF-Datei wird nicht gedruckt.

Ist es möglich die Procedur xlib_jasperreports.get_report erst dann beenden, wenn die PDF-Datei fertiggeschrieben ist? Möglich wäre es, wenn z.B. die gewünschte PDF-Datei zunächst mit einem eindeutigen temporären Dateinamen erstellt und zum Schluss in die vorgegebenen Dateinamen umbenannt wird.

Vielen Dank im Voraus Armen Grigorjan

--- Google Translator ---

Hello Mr Aust, We use your solution 99% of the time to create a PDF file, which is stored on the server and then processed. To process the PDF file (e.g. printing on printer XYZ), one text file is used per PDF file. This text file has the same name as the PDF file. For example, if the name of the PDF file is Test_1234.pdf, then the name of the text file is Test_1234.txt. The text file contains DOS commands, for example to print the PDF file on a network printer, send it by email, move it to a directory, etc. At the end of the text file, in 99% of cases, there is the command to delete the two files (PDF and TXT), as used for the example “DEL Test_1234.*” (we work in Windows world).

We use to create the PDF file xlib_jasperreports.get_report(p_rep_name => p_rep_name, p_rep_format => XLIB_JASPERREPORTS.C_REP_FORMAT_PDF, p_data_source => p_data_source, p_rep_locale => 'de-DE', p_rep_encoding => 'UTF-8', p_additional_params => p_additional_params, p_print_is_enabled => FALSE, p_print_printer_name => 'Dummy', p_print_media => 'iso-a4', p_print_copies => 1, p_print_duplex => FALSE, p_print_collate => FALSE, p_save_is_enabled => TRUE, p_save_filename => 'C:/PrintPDF/' || v_filename || '.pdf', p_out_blob => v_blob, p_out_mime_type => v_mime_type );

However, in PL/SQL the creation of the PDF file is done asynchronously. This means that if the PDF file is large, the file has not yet been written or closed and further functions are already being carried out in PL/SQL. In our specific example, the “Print” command being skipped and the “Delete” command being executed. The text file “disappears” and the PDF file is not printed.

Is it possible to end the xlib_jasperreports.get_report procedure once the PDF file has been written? It would be possible if, for example, the desired PDF file was first created with a unique temporary file name and finally renamed to the specified file name.

Thanks in advance Armen Grigorjan