Answers for "convert pdf to base64 javascript"


convert pdf to base64 javascript

// Check for the File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
  document.getElementById('files').addEventListener('change', handleFileSelect, false);
} else {
  alert('The File APIs are not fully supported in this browser.');

function handleFileSelect(evt) {
  var f =[0]; // FileList object
  var reader = new FileReader();
  // Closure to capture the file information.
  reader.onload = (function(theFile) {
    return function(e) {
      var binaryData =;
      //Converting Binary Data to base 64
      var base64String = window.btoa(binaryData);
      //showing file converted to base64
      document.getElementById('base64').value = base64String;
      alert('File converted to base64 successfuly!\nCheck in Textarea');
  // Read in the image file as a data URL.
Posted by: Guest on January-11-2021

Code answers related to "convert pdf to base64 javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language