I have the below in my HTML,
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
function displayStream(bytestream){
var data = btoa(bytestream);
console.log(data);
var obj ='<object type="application/pdf" width="100%" height="100%" border="2" class="pdfObject" data="data:application/pdf;base64,'+data+'" ></object>';
$('#divContainer').append(obj);
}
</script>
<title>Development </title>
</head>
<body>
<p id='output'> Below is the PDF </p>
<div id="divContainer">
</div>
</body>
</html>
I am getting the byte stream array in my ajax call and when I call the displayStream method it throws the below error in the developer console.
After converting the byte[] still, it is throwing the below error.
Can anyone advice how to display the PDF byte[] in an HTML page as a PDF within the DIV using javascript.