Enter your keyword

post

Convert Base 64 to PDF in Oracle Visual Builder

Convert Base 64 to PDF in Oracle Visual Builder

We came across one scenario where we need to call an external API that produces the PDF as a base64 string in response to the API and we need to allow users to download the PDF in Oracle Visual Builder.

LEARN ORACLE VISUAL BUILDER BY EXAMPLES

 

An END-END-END VB COURSE THAT WILL HELP YOU TO LEARN ORACLE VISUAL BUILDER quickly.

 

CLICK HERE TO BUY THIS COURSE.

As we all know, Oracle Visual Builder supports JavaScript which can help us to write custom logic as per our requirement so to convert the Base 64 String to PDF, we are going to write a JS that will do this conversion.

JavaScript code to convert base 64 string to PDF:

base64toPDF(data,invoiceid) {
var bString = window.atob(data);
var bLength = bString.length;
var bytes = new Uint8Array(bLength);
for (var i = 0; i < bLength; i++) {
var ascii = bString.charCodeAt(i);
bytes[i] = ascii;
}
var bufferArray = bytes;
var blobStore = new Blob([bufferArray], { type: "application/pdf" });
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blobStore);
return;
}
var data1 = window.URL.createObjectURL(blobStore);
var link = document.createElement('a');
document.body.appendChild(link);
link.href = data1;
link.download = invoiceid+".pdf";
window.open(data1,'_blank');
//link.click();
//window.URL.revokeObjectURL(data1);
//link.remove();
}

Recorded an end-to-end video to show this demonstration. Click on the following link to watch this demonstration:

If you like this article, please like, comment, and share. Request you to subscribe to my YouTube Channel for more such videos and click on bell icon to get regular updates.

Further readings:

Features of Oracle Integration 3

Oracle Integration | FBDI to upload AP into ERP

Place the file in ATP from BIP using OIC

Place the file in Object Storage from BIP using OIC

How to write files using an OIC FTP adapter

Read files from Object Storage in Oracle Integration

Access Object Storage from Oracle Integration

FTP adapter in Oracle Integration Cloud(OIC)