Skip to Main Content
Oracle Document Generator PL/SQL Package Owner

PDF Viewer

PDF Viewer

Create a Static Content Region (PDF Viewer)
Type: Static Content
Static ID: pdfViever
Source:

<div id="pdfViewer" style="width: 100%; height: 800px">
 <iframe src="" style="border: none;" type="application/pdf" width="100%" height="100%">
 </iframe>
</div>

Create a Classic Report (Generated Files)
Source:

SELECT
  id        
, file_name 
, created
, created_by
FROM
  pdf_files    

Add a “DERIVED” column Type: Link

<span class="fa fa-file-pdf-o" aria-hidden="true"></span>

Create a Custom DA (PDFViewer)
Event: Custom
Custom Event: PDFViewer
Selection Type: JavaScript Expression → document
True Action → Execute JavaScript Code:

const origin = window.location.origin;
const pathname = window.location.pathname;
const parts = pathname.split('/').filter(Boolean);
const workspace = pathname.split('/')[4];
const restURL = '' + origin + '/' + parts.slice(0, 2).join('/') + '/' + workspace + '/view/pdf/' ;
let id = this.data.id;
async function getData(){
   let afetch = await fetch ( restURL + id);
   let blob = await afetch.blob();
   let blobUrl = URL.createObjectURL(blob);
   let pdfContainer = document.getElementById('pdfViever') ;
   pdfContainer.getElementsByTagName('iframe')[0].src = blobUrl;
}
getData();

Create A Rest Module (PDFViewer)
Base Path: /view/
Generate a Template
URI Template: pdf/{id}
Priority: 0
HTTP Entity Tag Type: Secure Hash
Create Handler
Method: Get
Source Type: Media Source
Source:

SELECT
   file_mime
 , file_data
FROM
    pdf_files
WHERE
 id = :id

Done !