Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Display blob from database on Apex page

newjackDec 27 2018 — edited Jan 4 2019

Hello,

In Apex 5, we have a requirement to have several documents stored as blobs in the database be displayed on an apex page somehow, possibly in a region with the <embed> tag. Searching the forums hasn't revealed a solution.

We tried using the common code snippet

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/pdf'), 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: inline; 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;

but that only resulted in the below when trying to render the pdf from the above approach.

bad_pdf.png

Any guidance would be appreciated.

This post has been answered by raudabat on Jan 4 2019
Jump to Answer

Comments

InoL

...be displayed on an apex page somehow

To display an image, just use Display Image item type.

If not an image, what documents are you talking about to be displayed? Typically, documents are downloaded. For PDF, there is a plugin to show the pdf directly on a page.

http://www.apex-plugin.com/oracle-apex-plugins/item-plugin/pdfembedded_337.html

raudabat
Answer

I think you are missing the htp.init;   at the start of your routine. This will happen in Firefox if this is not set.

Hope this works.

Tom

Marked as Answer by newjack · Sep 27 2020
newjack

This is a pdf. I will give the plugin a look.

newjack

This was helpful. The pdf is not rendering but the pdf container displayed.  Thank you!

1 - 4

Post Details

Added on Dec 27 2018
4 comments
1,497 views