Skip to Main Content

Display PDF in a PL/SQL Region - APEX 4.2

Hawk333Jun 19 2015 — edited Jun 23 2015

I'm trying to display a pdf in a PL/SQL region in the same APEX page. First, I've gone through the following threads, but none of them worked for me:

How to display pdf file in apex region

Show PDF ....

I have a PL/SQL dynamic region with the source:

declare

n_file_id number;

v_file    varchar2(255);

v_source  varchar2(255);

begin

v_source := 'MAXIS_RENEWAL.DRIVER_FILE_API.download_file_upload?p_file='||:P250_X_FILE_ID;

HTP.P(V_SOURCE);

htp.p('<div style="">');

htp.p('<embed height="900" width="800" name="embed_content" src="'||v_source||'" type="application/pdf" />');

htp.p('</div>');

end

The procedure download_file_upload is as follows:

PROCEDURE DOWNLOAD_FILE_UPLOAD(p_file in number ) AS

        v_mime  VARCHAR2(4000);

        v_length  NUMBER;

        v_file_name VARCHAR2(2000);

        Lob_loc  BLOB;

        LOC VARCHAR2(10);

      

BEGIN

        SELECT MIME_TYPE, BLOB_CONTENT, filename,DBMS_LOB.GETLENGTH(blob_content)

                Into V_Mime,Lob_Loc,V_File_Name,V_Length

                FROM MAXIS_RENEWAL.library_docs_imp

                WHERE id = p_file;

              --

              -- set up HTTP header

              --

                    -- use an NVL around the mime type and

                    -- if it is a null set it to application/octect

                    -- application/octect may launch a download window from windows

                    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );

                -- set the size so the browser knows how much to download

                htp.p('Content-length: ' || v_length);

                -- the filename will be used by the browser if the users does a save as

                --htp.p('Content-Disposition:  attachment; filename="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');

                htp.p('Content-Disposition:  inline; filename="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');

                -- close the headers

            

                owa_util.http_header_close;

                -- download the BLOB

           

                wpg_docload.download_file( Lob_loc );

exception when others then

   --log error

   htp.p('ERROR DOWNLOAD FILE: '||sqlerrm);

end download_file_upload;

With the current version, it only downloads the pdf on FireFox and IE. On Chrome, it won't. It will only display the string  "MAXIS_RENEWAL.DRIVER_FILE_API.download_file_upload?p_file=xxxsomeID" in the region.

When I copy the string and past in the browser url, it downloads the files.

I really cannot figure out the problem. Any help is deeply appreciated.

This post has been answered by Kiran Pawar on Jun 23 2015
Jump to Answer
Comments
Post Details
Added on Jun 19 2015
6 comments
3,271 views