Forum Stats

  • 3,871,977 Users
  • 2,266,360 Discussions
  • 7,911,017 Comments

Discussions

PDF Viewer in APEX error in REST and getElementsByTagName()

Scott Sutherland
Scott Sutherland Member Posts: 15 Green Ribbon

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();
Tagged: