Senin, 24 Juli 2017

Implementing PDF.js on Oracle APEX

Here step by step preparation :


  • Install PDF.js under image prefix apex

  • Prepare Download page helper
    • Page with alias : DOWNLOAD_PDF
    • Process : before header
    • declare
        r_data EMP_PDF%rowtype;
      BEGIN
        select * into r_data
          from emp_pdf
         where empno = :P4_EMPNO;
          sys.htp.init;
          sys.owa_util.mime_header( r_data.mimetype, FALSE);
          sys.htp.p('Content-length: ' || sys.dbms_lob.getlength( r_data.pdf_data ));
          sys.htp.p('Content-Disposition: inline; filename='||r_data.filename );
          -- tell the browser to cache for one hour, adjust as necessary
          sys.htp.p('Cache-Control: max-age=3600');
          sys.owa_util.http_header_close;
          
          sys.wpg_docload.download_file(r_data.pdf_data);
          apex_application.stop_apex_engine;
      exception when others then
          sys.htp.prn('error: '||sqlerrm);
          apex_application.stop_apex_engine;
      END;
      
Case 1 : On form
  • Create Static Region

  • Preview

Case 2 : On Tabular form