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!

View PDFs on Mobile Devices

Veerendra PatilDec 29 2020 — edited Dec 29 2020

Hi,
I am using APEX19.1, DB-12c, hosted on AWS
Browser - Chrome - Version 87.0.4280.88 (Official Build) (x86_64)
I have a mobile app, using UT Red theme.
I have a page where I display PDFs from DB.
I am able to get it working correctly on big devices. The PDF renders correctly.
However, on laptops - when I inspect element and change the device type to any mobile/tabs, the PDFs fails to open giving Plugin-blocked and nothing is displayed . I get an error as shown
Screenshot 2020-12-29 at 21.38.49.png
Screenshot 2020-12-29 at 22.26.28.png
The same happens on actual mobile device as well
My sample code to display PDF is
Type 1 - Dynamic PLSQL Content
DECLARE
v_blob BLOB := empty_blob();
l_step number := 22500;
BEGIN
if (:P21_ID is not null) then
select blob_content
into v_blob
from my_table
where id = :P21_ID;

DBMS_LOB.OPEN(v_blob, DBMS_LOB.LOB_READONLY);
htp.p( '<embed src="data:application/pdf;base64,' );
for i in 0 .. trunc((dbms_lob.getlength(v_blob) - 1 )/l_step) loop
htp.p( utl_raw.cast_to_varchar2(utl_encode.base64_encode(dbms_lob.substr(v_blob, l_step, i * l_step + 1))));
end loop;
htp.p('" height="600" width="100%" >');
DBMS_LOB.CLOSE(v_blob);
else
htp.p('Invalid File ID');
end if;
EXCEPTION WHEN OTHERS THEN
htp.p('No File ID');
END;

Type 2 - Static Region
<embed width="100%" height="1000" src="f?p=&APP_ID.:0:&APP_SESSION.:APPLICATION_PROCESS=GETPDF::::">
Type 3 - PLSQL Dynamic Content
DECLARE
l_b64_clob CLOB;
BEGIN
select APEX_WEB_SERVICE.BLOB2CLOBBASE64(blob_content)
into l_b64_clob
from my_table
where id = :P21_ID;
htp.prn('<object data="data:application/pdf;base64,'||l_b64_clob||'" type="application/pdf" width="100%" height="600"/>');
END;
Type 4 - Webservice
I created a web-service to show PDF - Works fine.
Page processing - Create Branch before header - The Webservice URL
I tried with iframe/embed/object tags. All works fine on large screens. but not on mobile.
Can you please suggest how to render PDFs on mobile devices?

Thanks,
Veerendra.

Comments
Post Details
Added on Dec 29 2020
4 comments
425 views