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.

How to read/view a BLOB Column value(Word doc/PDF files content) without download in Oracle Apex Interactive\Classic Report?

Sabarinath ASep 13 2023 — edited Sep 21 2023

I stored BLOB column (word files) in Table. In Oracle APEX, I want to read or view\display that BLOB column such as Word\PDF files contents in Interactive/Classic Report so that the user can read the word/PDF documents without downloading it.. How to achieve/do that? Is it possible to view the BLOB columns such as Word\PDF files contents in Oracle APEX(23.1.2)? Can anyone please suggest/assist me how to I get/develop that?

Comments

Sabarinath A

Can anyone please assist to me

user3377998

Hi

There are two options. One to download the blob and one to display the blob.

The table containing the blob should have columns for storing mime_type, filename, last_updated and characterset

You can select the blob in your sql-statment by using dbms_lob.getlenght(blob column).

select id, dbms_lob.getlenght(blob column) image from table1;

Define the column in the report as Download BLOB. Set all the required attributes for the Download BLOB column.

install and review the file upload/download sample app for how to do this

Sabarinath A

Hi, You answered BLOB column Download option. But, I need to read the word files content(stored BLOB column) from Classic/Interactive Report. I don't want to download option. How to do? Thanks in Advance

Sabarinath A

Hi, You answered BLOB column Download option. But, I need to read the word files content(stored BLOB column) in Classic Report. I don't want to download option. How to do that? Please suggest me.

user3377998

Insted of Download BLOB you pick Display Image. But I will not garantee that the browser will display a WORD-document. It will require some extra coding and setup. But for pdf and png which the browser supports it should work.

Jayson Hanes - APEX PM North America-Oracle

Based on your requirements it sounds like you should explore the tools available from United Codes, DOCX Templates | APEX Office Print (AOP)

Sabarinath A

Thanks for suggested me. But there is no display docs option and also not give detailed summary.

Carsten Czarski-Oracle

So, you're after extracting text from the DOCS or PDF document and display it directly on the page, right?

If that's the case, there is some functionality in the database, you might find useful: have a look into the CTX_DOC.POLICY_FILTER function. That function converts a BLOB containing PDF or Word contents to a CLOB containing the clear text or HTML representation. You might play with that a bit …

The API is not too developer-friendly (procedure with OUT parameters), so you might build yourself a bit of wrapper code to make the functionality easier to consume in your APEX app …

begin
  ctx_ddl.drop_policy(
    policy_name => 'filter_policy'
  );
end;
/
sho err

begin
  ctx_ddl.create_policy(
    policy_name => 'filter_policy',
    filter      => 'CTXSYS.AUTO_FILTER'
  );
end;
/
sho err

create or replace function filter_document(
  p_document in blob
) return clob
is
  l_data clob;
begin
  dbms_lob.createtemporary(
    lob_loc => l_data, 
    cache   => true, 
    dur     => dbms_lob.call
  );
  ctx_doc.policy_filter(
    policy_name => 'filter_policy',
    document    => p_document, 
    restab      => l_data
  );
  return l_data;
end;
/
sho err

With that in place, you can simply convert by calling your FILTER_DOCUMENT function …

I hope this helps

-Carsten

1 - 9

Post Details

Added on Sep 13 2023
9 comments
2,023 views