Guest User

Untitled

a guest
Jul 22nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. DECLARE
  2. v_blob BLOB;
  3. v_file_name VARCHAR2 (25) := lower(:P14_RODZAJ)||'.pdf';
  4. v_vcContentDisposition VARCHAR2 (25) := 'inline';
  5.  
  6.  
  7. v_hostname VARCHAR2(30) := 'localhost'; -- your hostname, eg: localhost
  8. v_port NUMBER := '8081'; -- port for your JasperReports Server, eg: 8081
  9. v_username VARCHAR2(50) := 'jasperadmin'; -- jasperreports server username
  10. v_password VARCHAR2(50) := 'jasperadmin'; -- jaspereports server password
  11.  
  12. v_jasper_string VARCHAR2(30) := v_username || ';' || v_password;
  13.  
  14. v_login_url VARCHAR2(100) :=
  15. 'http://' || v_hostname || ':' || v_port || '/jasperserver/rest/login';
  16. -- modify below URL before use!
  17. -- you should modify the line below; change /Pretius/ to your own name
  18. -- before you add a line try your URL in a web browser
  19. v_report_url VARCHAR2(100) :=
  20. 'http://' || v_hostname || ':' || v_port || '/jasperserver/rest_v2/reports/reports/DokumentySprzedazy/' || v_file_name;
  21. BEGIN
  22.  
  23. -- log into jasper server
  24. v_blob := apex_web_service.make_rest_request_b(
  25. p_url => v_login_url,
  26. p_http_method => 'GET',
  27. p_parm_name => apex_util.string_to_table('j_username;j_password',';'),
  28. p_parm_value => apex_util.string_to_table(v_jasper_string,';')
  29. );
  30.  
  31. -- download file
  32. v_blob := apex_web_service.make_rest_request_b(
  33. p_url => v_report_url,
  34. p_http_method => 'GET',
  35. p_parm_name => apex_util.string_to_table('NumerZamowienia;Rodzaj;NumerDokumentu',';'),
  36. p_parm_value => apex_util.string_to_table(:P14_NRZAMOWIENIA||';'||:P14_RODZAJ||';'||:P14_NRDOKUMENTU,';')
  37. );
  38.  
  39. OWA_UTIL.mime_header ('application/pdf', TRUE); -- view your pdf file
  40. OWA_UTIL.MIME_HEADER( 'application/octet', FALSE ); -- download your pdf file
  41. HTP.p('Content-Length: ' || DBMS_LOB.GETLENGTH(v_blob));
  42. HTP.p('Content-Disposition: ' || v_vcContentDisposition ||'; filename="' || v_file_name || '"');
  43. OWA_UTIL.http_header_close;
  44. WPG_DOCLOAD.DOWNLOAD_FILE(v_blob);
  45.  
  46. APEX_APPLICATION.STOP_APEX_ENGINE;
  47.  
  48. EXCEPTION
  49. WHEN OTHERS THEN
  50. RAISE;
  51.  
  52. END;
Add Comment
Please, Sign In to add comment