How to download PDF Report form Oracle Application Express

  • Create PL/PDF Report Procedure or Package
  • Create Download Procedure
create or replace procedure download_plpdf(
  p_filename in varchar2,
  p_document in out nocopy blob
  ) is
  l_mimetype varchar2(100 char) := 'application/pdf';
begin
  sys.htp.init;
  sys.owa_util.mime_header(l_mimetype, false);
  sys.htp.p('Content-length: ' || sys.dbms_lob.getlength(p_document));
  sys.htp.p('Content-Disposition: download; filename="' || p_filename || '"');
  sys.htp.p('Cache-Control: max-age=3600');
  sys.owa_util.http_header_close;
  sys.wpg_docload.download_file(p_document);
  apex_application.stop_apex_engine; --APEX!
end;
  • Set the Page: Reload on submit: Always (On The page that is calling the download process)

  • Create Page PL/SQL Proccess

  • Add Report and download code
begin
-- Call the procedure
  rep1.genpdf;
--download
download_plpdf(
  p_filename => 'rep1.pdf',
  p_document => rep1.v_pdf
  )  
--
end;

Test