2

How can we display a PDF using JavaScript from a base64 in Google chrome? As application:PDF,base64:pdfbase64binary is not working anymore

dexter
  • 21
  • 1
  • 2

2 Answers2

0

You can use a Blob URL to represent the file.

fetch(<data URI>)
.then(response => response.blob())
.then(blob => {
  // do stuff with `Blob URL`
  const blobURL = URL.createObjectURL(blob);
});

See Creating a Blob from a base64 string in JavaScript, also Base64 PDF in new tab shows Blank Page before Refresh.

guest271314
  • 1
  • 15
  • 104
  • 177
0
window.open("data:application/octet-stream;base64," + response)
Buddy
  • 10,874
  • 5
  • 41
  • 58