Show PDF ....
894843Nov 30 2011 — edited Mar 26 2013Hi all..
APEX: 4.1
Database:11g
APEX Listener
How can i show a PDF DOC in the browser without giving a download option to the users?
I have a PDF doc saved in the database as a BLOB content.
I am using the following PROC to download the PDF from the database.
Everything is working fine, I am able to download the PDF from the database.
But instead of downloading i want to show the PDF in a separate browser(inline)
I tried changing ""'Content-Disposition:""" to ""inline"".
My code:
I have a button on a page..
with URL target as
{code}
javascript:open_pdf_doc();
{code}
{code}
function open_pdf_doc() {
var v_url = 'download_doc?i_doc_id=' + '&P405_DOC_ID.';
window.location.href = v_url;
}
{code}
{code}
create or replace
PROCEDURE download_doc(i_doc_id in number) AS
v_mime VARCHAR2(48) := 'PDF' ;
v_length NUMBER;
v_filename VARCHAR2(200);
v_blob BLOB;
BEGIN
SELECT doc_image, DBMS_LOB.GETLENGTH(doc_image), doc_filename
INTO v_blob , v_length, v_filename
FROM test_download_doc
WHERE doc_id = to_number(i_doc_id);
--
-- 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="'||replace(replace(substr(v_filename,instr(v_filename,'/')+1),chr(10),null),chr(13),null)|| '"');
-- close the headers
owa_util.http_header_close;
-- download the BLOB
wpg_docload.download_file( v_blob );
end download_doc;
{code}
Thank you...