Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE
- v_blob BLOB;
- v_file_name VARCHAR2 (25) := lower(:P14_RODZAJ)||'.pdf';
- v_vcContentDisposition VARCHAR2 (25) := 'inline';
- v_hostname VARCHAR2(30) := 'localhost'; -- your hostname, eg: localhost
- v_port NUMBER := '8081'; -- port for your JasperReports Server, eg: 8081
- v_username VARCHAR2(50) := 'jasperadmin'; -- jasperreports server username
- v_password VARCHAR2(50) := 'jasperadmin'; -- jaspereports server password
- v_jasper_string VARCHAR2(30) := v_username || ';' || v_password;
- v_login_url VARCHAR2(100) :=
- 'http://' || v_hostname || ':' || v_port || '/jasperserver/rest/login';
- -- modify below URL before use!
- -- you should modify the line below; change /Pretius/ to your own name
- -- before you add a line try your URL in a web browser
- v_report_url VARCHAR2(100) :=
- 'http://' || v_hostname || ':' || v_port || '/jasperserver/rest_v2/reports/reports/DokumentySprzedazy/' || v_file_name;
- BEGIN
- -- log into jasper server
- v_blob := apex_web_service.make_rest_request_b(
- p_url => v_login_url,
- p_http_method => 'GET',
- p_parm_name => apex_util.string_to_table('j_username;j_password',';'),
- p_parm_value => apex_util.string_to_table(v_jasper_string,';')
- );
- -- download file
- v_blob := apex_web_service.make_rest_request_b(
- p_url => v_report_url,
- p_http_method => 'GET',
- p_parm_name => apex_util.string_to_table('NumerZamowienia;Rodzaj;NumerDokumentu',';'),
- p_parm_value => apex_util.string_to_table(:P14_NRZAMOWIENIA||';'||:P14_RODZAJ||';'||:P14_NRDOKUMENTU,';')
- );
- OWA_UTIL.mime_header ('application/pdf', TRUE); -- view your pdf file
- OWA_UTIL.MIME_HEADER( 'application/octet', FALSE ); -- download your pdf file
- HTP.p('Content-Length: ' || DBMS_LOB.GETLENGTH(v_blob));
- HTP.p('Content-Disposition: ' || v_vcContentDisposition ||'; filename="' || v_file_name || '"');
- OWA_UTIL.http_header_close;
- WPG_DOCLOAD.DOWNLOAD_FILE(v_blob);
- APEX_APPLICATION.STOP_APEX_ENGINE;
- EXCEPTION
- WHEN OTHERS THEN
- RAISE;
- END;
Add Comment
Please, Sign In to add comment