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.

PDF Viewer in APEX error in REST and getElementsByTagName()

Scott SutherlandJul 29 2022

Hi
Am reviewing the viewing of PDF in APEX and tried out the steps in the Oracle Developers "PDF Viewer in Oracle APEX" https://www.youtube.com/watch?v=PoAl_TA0TxA
Am working in https://cloud.oracle.com/
The code is explained at 1:43 and updated at 3:43 with the REST URL in the video.
1. REST
error " ... 404 (Not Found) for code =

let afetch = await fetch("https://g18a2de1c5ca5ff-databasetwo.adb.af-johannesburg-1.oraclecloudapps.com/ords/SCOTT_DEV/demopdfviewer/examplepdf/" + id);

Can anyone advise where I can find a solution? I am not familiar with REST so I'm not sure how to go about this, so I should probably read up more about this
2. getElementsByTagName
error "...TypeError: Cannot read properties of null (reading 'getElementsByTagName') at getData " for code

pdfContainer.getElementsByTagName("iframe") [0].src = blobUrl;

What could be the error? Code is as per demo - have experimented with using 'NULL' in place of '0" but no difference in the outcome
FYI full code snippet is

let id = this.data.id; 
async function getData() {
    let afetch = await fetch("https://g18a2de1c5ca5ff-databasetwo.adb.af-johannesburg-1.oraclecloudapps.com/ords/SCOTT_DEV/demopdfviewer/examplepdf/" + id);
  let blob = await afetch.blob();
  let blobUrl = URL.createObjectURL(blob);
  let pdfContainer = document.getElementById("pdfViewer");

  pdfContainer.getElementsByTagName("iframe") [0].src = blobUrl;
}
getData();

Comments

Post Details

Added on Jul 29 2022
0 comments
635 views